(相关资料图)
查找星期pta,查找星期这个很多人还不知道,现在让我们一起来看看吧!
1、程序写得太繁琐了。
2、原程序已经修正完成:#include#include#defineMAXS80intgetindex(char*s);intmain(){intn;chars[MAXS];scanf("%s",s);n=getindex(s);if(n==-1)printf("wronginput!");elseprintf("%d",n);return0;}intgetindex(char*s){if(strcmp(s,"Sunday")==0){return0;}elseif(strcmp(s,"Monday")==0){return1;}elseif(strcmp(s,"Tuesday")==0){return2;}elseif(strcmp(s,"Wednesday")==0){return3;}elseif(strcmp(s,"Thursday")==0){return4;}elseif(strcmp(s,"Friday")==0){return5;}elseif(strcmp(s,"Saturday")==0){return6;}else{return-1;}}。
本文到此分享完毕,希望对大家有所帮助。