/编写一个程序,从标准输入一行一行地读取文本,如果相邻出现重复内容,则打印出其中一行,其余的不打印

 1 //编写一个程序,从标准输入一行一行地读取文本,如果相邻出现重复内容,则打印出其中一行,其余的不打印
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #include <string.h>
 5 int main()
 6 {
 7     char str1[128];
 8     char str2[128];
 9     int r;
10     memset(str1,0,128);
11     memset(str2,0,128);
12     while(gets(str1) != NULL){
13         r = strcmp(str1,str2);
14         if(r)
15         {
16             printf("
");
17             puts(str1);
18             printf("
");
19         }
20         strcpy(str2,str1);
21     }
22     system("pause");
23         return 0;
24 }
原文地址:https://www.cnblogs.com/joyclub/p/4480171.html