C语言的小程序,初学者提问

来源:百度知道 编辑:UC知道 时间:2024/06/19 13:14:41
随意输入一组数组
然后倒叙输出

不知道是否能满足你的需求

#include <stdio.h>
#include <ctype.h>
#define MAX 1024

void main()
{
char a[MAX];
int i, j, endpos, startpos;
printf("Input array end with @ :\n");
for(i=0; i<MAX; i++)
{
scanf("%c", &a[i]);
if(a[i] == '@')
{
i--;
break;
}
}

while(i > 0)
{
while(isspace(a[i])||a[i]=='\n')
{
i--;
}
endpos = i;

while(!(isspace(a[i])||a[i]=='\n') && i >= 0)
{
i--;
}
startpos = i + 1;
for(j = startpos; j <= endpos; j++)
{
printf("%c", a[j]);
}
printf("\n");
}
}