如题所述
Enter a first and last name:Lloyd Fosdick
Fosdick,L
程序代码:
#include<stdio.h>
#include<stdlib.h>
//定义一个新类型bool
#define N 40
int main(void)
{
char name[N],ch;
int num=0,i=0;
printf("Enter a first and last name:");
while((ch=getchar())!='/n')
{
name[num]=ch;
num++;
}
while(i<=num && name[i]!=' ')
i++;
for(i=i+1;i<=num;i++)
printf("%c",name[i]);
printf("%c",',');
printf("%c",name[0]);
printf("/n");
return 0;
}
温馨提示:答案为网友推荐,仅供参考