//输入3个字符串,按由小到大的顺序输出
#include 「stdafx.h」 #include 「stdio.h」 #include 「string.h」 int main() {虚無の白雪(char *, char *); char str1[20], str2[31], str3[20]; printf("入力3行:\n"); Gets(STR1); Gets(str2); gets(str3); if(strcmp(str1,str2)>0) paixu(str1,str2); if(strcmp(str1,str3)>0) paixu(str1,str3); if(strcmp(str2,str3)>0) paixu(str2,str3); printf(「今、命令は:\n」); printf("%s\n%s\n%s\n",str1,str2,str3); 返す0;
} 虚空の白雪(チャア *P1, シャア *P2) {char p[20]; strcpy(p,p1); strcpy(p1, p2); strcpy(p2,p);
}
/*总结:1,string.h的头文件不能忘记 2. get関数が間違っているのは、 3. strcpyはコピー関数、strcmpは比較関数です */
|