//习题 10.1 编写一个程序,读入,存储以及输出下列5种类型的字符串, //每个字符串占一行,字符串间不能有空格。 // 类型1:一串小写字母,后面跟一数字(如number1) // 类型2:两个字单词,每个单词的第一个字母大写,单词间用-分隔(如Seven-Up) // 类型3:小数(如7.35) // 类型4:一串大小写字母及空格(如Oliver Hardy) // 类型5:一除了空格及数字外的任何字符串(如floating-point) // 以下是这五种字符串类型的例子,要分开读入这些字符串: // babylon5John-BOy3.14159STan Laurel'winner!' #include<stdio.h> #include<stdbool.h> #define len 80 int main(void) { bool k=true; char word1[len]="\0"; char word2[len]="\0"; char word3[len]="\0"; char word4[len]="\0"; char word5[len]="\0"; char temp1[len], temp2[len], temp3[len],temp4[len] ,temp5[len], temp6[len], temp7[len], temp8[len] ,temp9[len], temp10[len]="\0"; while(k) { printf("\nplease enter the five strings"); if(10!=scanf_s("%[a-z]%1[0-9]%1[A-Z]%[a-zA-Z]" "%[-]%1[A-Z]%[a-zA-Z]%[0-9.-]%[a-zA-Z ]%[^ 0-9\n]", temp1,len,temp2,len,temp3,len, temp4,len,temp5,len,temp6,len,temp7, len,temp8,len,temp9,len,temp10,len)) { printf("\nerror enter"); fflush(stdin); } else { printf("sssss"); strcat_s(word1,len,temp1); strcat_s(word1,len,temp2); strcat_s(word2,len,temp3); strcat_s(word2,len,temp4); strcat_s(word2,len,temp5); strcat_s(word2,len,temp6); strcat_s(word2,len,temp7); strcat_s(word3,len,temp8); strcat_s(word4,len,temp9); strcat_s(word5,len,temp10); k=false; } } printf_s("\n%s\n%s\n%s\n%s\n%s",word1,word2,word3,word4,word5); return 0; }