码迷,mamicode.com
首页 > 其他好文 > 详细

PAT 甲级 A1061 (2019/02/09) NULL(16/20)

时间:2019-02-21 23:04:26      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:char   print   div   a10   turn   scan   flag   har   ==   

 1 #include<cstdio>
 2 #include<cstring>
 3 int main(){
 4     char str1[61], str2[61], str3[61], str4[61];
 5     char week[7][4]={"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
 6     scanf("%s", &str1);
 7     scanf("%s", &str2);
 8     scanf("%s", &str3);
 9     scanf("%s", &str4);
10     int len1 = strlen(str1), len3 = strlen(str3);
11     bool flag = false;
12     for(int i = 0; i < len1; i++){
13         if(flag == false && str1[i] == str2[i] && str1[i]>A && str1[i]<G){
14             printf("%s ", week[str1[i] - A]);
15             flag = true;
16             continue;
17         }
18         if(flag == true && str1[i] == str2[i]) {
19             if(str1[i] >= 0 && str1[i] <= 9) {
20                 printf("%02d:", str1[i] - 0);
21                 break;
22             }
23             if(str1[i] >= A && str1[i] <= N) {
24                 printf("%02d:", str1[i] - A + 10);
25                 break;
26             }
27         }    
28     }
29     for(int i= 0; i < len3; i++){
30         if(str3[i] == str4[i] && ((str3[i] >= a && str3[i] <= z)||(str3[i] >= A  && str3[i] <= Z))){
31             printf("%02d",i);
32             break;
33         }
34     }
35     return 0;
36 } 

 

PAT 甲级 A1061 (2019/02/09) NULL(16/20)

标签:char   print   div   a10   turn   scan   flag   har   ==   

原文地址:https://www.cnblogs.com/zjsaipplp/p/10415813.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!