PAT 乙级1014. 福尔摩斯的约会(C语言版)
来源:互联网 发布:linux环境变量配置 编辑:程序博客网 时间:2024/05/17 00:16
include
include
define BUFFER_SIZE 60
/* run this program using the console pauser or add your own getch, system(“pause”) or input loop */
void weekday(char c,char tmp[]);
int main(int argc, char** argv) {
char str[BUFFER_SIZE],str1[BUFFER_SIZE],str2[BUFFER_SIZE],str3[BUFFER_SIZE],str4[BUFFER_SIZE];scanf("%s%s%s%s",&str1,&str2,&str3,&str4);
// strcpy(str1,”3485djDkxh4hhGE”);
// strcpy(str2,”2984akDfkkkkggEdsb”);
// strcpy(str3,”s&hgsfdk”);
// strcpy(str4,”d&Hyscvnm”);
// str1 = “3485djDkxh4hhGE”;
// str2 = “2984akDfkkkkggEdsb”;
// str3 = “s&hgsfdk”;
// str4 = “d&Hyscvnm”;
int len1 = strlen(str1);
int len2 = strlen(str2);
int len3 = strlen(str3);
int len4 = strlen(str4);
if(len1 > 60 || len2 > 60 || len3 > 60 || len4 > 60 ||
len1 < 1 || len2 < 1 || len3 < 1 || len4 < 1 ){
return 0;
}
// printf(“读入的 %s\n%s\n%s\n%s\n”,&str1,&str2,&str3,&str4);
int i = 0,cnt = 0;
while(str1[i] != '\0' || str2[i] != '\0'){ char c1 = str1[i]; char c2 = str2[i]; if( c1 == c2 ){ //算出了星期几才会走到这个If if(cnt == 1 ){ if( c1 >= '0' && c1 <='9'){ printf("0%d:",c1-'0'); break; } if( c1 >='A' && c1 <= 'N'){ printf("%d:",c1-'A'+10); break; } } //这里有2个测试点,要<G if( c1 >= 'A' && c2 <= 'G'){ // printf("c1 = %c\n",c1); weekday(c1,str); cnt++; printf("%s ",str); } } //printf("%c\t",str1[i]); i++;}i = 0;while(str3[i] != '\0' || str4[i] != '\0'){ char c3 = str3[i]; char c4 = str4[i]; if(c3 == c4){ if( (c3 >= 'a' && c3 <= 'z') || (c3 >= 'A' && c3 <= 'Z')){ if( i < 10){ printf("0%d",i); }else{ printf("%d",i); } break; } } i++;}return 0;
}
//将星期几copy到传入的数组中
void weekday(char c,char tmp[]){
int t = c - 'A' + 1;if( t == 1){ strcpy(tmp,"MON"); }else if( t == 2){ strcpy(tmp,"TUE"); } else if( t == 3){ strcpy(tmp,"WED"); } else if( t == 4){ strcpy(tmp,"THU"); } else if( t == 5){ strcpy(tmp,"FRI"); } else if( t == 6){ strcpy(tmp,"SAT"); } else if( t == 7){ strcpy(tmp,"SUN"); } else { strcpy(tmp,""); }
}
- PAT 乙级1014. 福尔摩斯的约会(C语言版)
- PAT(乙级)1014. 福尔摩斯的约会
- PAT乙级 1014. 福尔摩斯的约会 C语言
- PAT乙级 1014. 福尔摩斯的约会
- PAT 乙级 1014. 福尔摩斯的约会
- 1014. 福尔摩斯的约会 (20) PAT 乙级
- PAT-乙级-1014. 福尔摩斯的约会 (20)
- PAT.乙级1014. 福尔摩斯的约会 (20)
- 1014. 福尔摩斯的约会 (20)-PAT乙级
- [PAT-乙级]1014.福尔摩斯的约会
- PAT乙级 1014. 福尔摩斯的约会 (20)
- PAT乙级1014. 福尔摩斯的约会 (20)
- PAT乙级 1014. 福尔摩斯的约会 (20)
- [PAT乙级]1014. 福尔摩斯的约会 (20)
- 1014. 福尔摩斯的约会 (20)--PAT乙级
- PAT乙级题1014.福尔摩斯的约会
- PAT乙级1014. 福尔摩斯的约会(20)
- 【PAT】(乙级)1014. 福尔摩斯的约会 (20)
- ajax实时刷新
- List与Set的基础知识
- 可视化工具--D3--案例分析--Chord Diagram
- IONIC WebApp之tabs框架样式修改
- 大数据系列修炼-Scala课程04
- PAT 乙级1014. 福尔摩斯的约会(C语言版)
- 【HDU5783】Divide the Sequence(贪心)
- Python 2-3的坑
- 文章标题
- UVA 11270 Tiling Dominoes(用1×2骨牌覆盖n×m棋盘,有多少种方法)
- 转载一篇个人觉得不错的关于对象引用的文章
- 生成Description
- BC#86.1002(HDOJ5805)NanoApe Loves Sequence
- 位运算及其应用详解