如何用指针的方法,输入一行字符串,并在每个字母之间插入空格

慕容5342564
浏览 1364回答 1
1回答

___C___

#include <stdio.h>#include <ctype.h>#define N 1024int main(){ char s[N]; int i=N; while((*(s+(--i))=getchar ())!='\n'); *(s+i) = 0; i=N-1; for(int j=0;*(s+i);i--){ *(s+(j++)) = *(s+i); if(isalpha(*(s+i)) && isalpha(*(s+i-1)))s[j++] = ' '; } *(s+j) = 0; puts(s); return 0;}谢谢采纳
打开App,查看更多内容
随时随地看视频慕课网APP