以下是引用论坛在2006-7-17 21:34:14的发言:
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int number;
int index;
int i;
int character = 65;
printf("Enter number: \n");
scanf("%d", &number);
if (number < 1)
{
number = 1;
}
else if (number > 26)
{
number = 26;
}
for (index=1; index<=number; index++)
{
for (i=1; i<=index; i++)
{
putc(character, stdout);
}
putc('\n', stdout);
character++;
}
exit(0);
}
写成一行 不行吗? 为什么要分开写呢? 有什么好处吗?