永发信息网

c语言编写程序颠倒句子enter a sentence:you can case a swallow

答案:2  悬赏:70  手机版
解决时间 2021-02-19 09:30
  • 提问者网友:愿为果
  • 2021-02-18 10:23
c语言编写程序颠倒句子enter a sentence:you can case a swallow
最佳答案
  • 五星知识达人网友:逐風
  • 2021-02-18 11:58
#include <stdio.h>#include <stdlib.h>#include <string.h>#include<ctype.h>#define OK 1#define M 5//建单词节点struct Node{\x09char *data;\x09Node *next;};char f;//插入函数void Insert(Node* &S,char e[]){\x09Node *p;\x09p=(Node *)malloc(sizeof(Node));\x09p->data = (char *)malloc(strlen(e)+1);\x09p->next = NULL; strcpy(p->data,e);\x09p->next = S;\x09S = p;}void Creat(Node* &S){\x09int i = 0,k = 0,j,flag = 1,insert;\x09char s[20];\x09char a[2000] = {0}; printf("\n输入正文: ");\x09fflush(stdin); \x09gets(a); printf("\n原文为: ");\x09while(a[i] != NULL)\x09{\x09\x09insert = 0;\x09\x09memset(s, 0, 20);\x09\x09j = 0;\x09\x09// 跳过单词前面的前导字符\x09\x09while(flag&&!isalpha(a[i])||a[i]==39)//39为'的ASCII码\x09\x09{\x09\x09\x09i++;\x09\x09\x09if(a[i]==NULL)\x09\x09\x09\x09flag = 0;\x09\x09}\x09\x09// 当前单词尚未结束,则一直循环\x09\x09while(flag&&isalpha(a[i])||a[i]==39)\x09\x09{\x09\x09\x09insert = 1;\x09\x09\x09s[j]=tolower(a[i]);\x09\x09\x09i++;\x09\x09\x09j++;\x09\x09}\x09\x09//单词插入\x09\x09if(insert)\x09\x09{\x09\x09\x09s[i] = '\0';\x09\x09\x09k++;\x09\x09\x09printf("%s\t", s);\x09\x09\x09if(k%5 == 0)\x09\x09\x09\x09printf("\n");
全部回答
  • 1楼网友:猎心人
  • 2021-02-18 13:16
收益了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯