福尔摩斯

PTA乙级 (1014 福尔摩斯的约会 (20分)、(英文字母转换成数字类型))

邮差的信 提交于 2020-02-02 22:32:56
1014 福尔摩斯的约会 (20分) https://pintia.cn/problem-sets/994805260223102976/problems/994805308755394560 英文字母转换成数字类型: 代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; int main() { int length1,length2,count=0; string str1,str2,str3,str4; cin>>str1>>str2>>str3>>str4; int len1=str1.length(); int len2=str2.length(); int len3=str3.length(); int len4=str4.length(); if(len1<len2) length1=len1;else length1=len2; if(len3<len4) length2=len3;else length2=len4; for(int i=0;i<length1;i++) { if((str1[i]==str2[i])&&(str1[i]>='A'

1014 福尔摩斯的约会

喜夏-厌秋 提交于 2020-01-10 11:16:25
#include <cstdio> char a[65], b[65], c[65], d[65]; char *week[] = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" }; int main() { while( ~scanf( "%s%s%s%s", a, b, c, d ) ) { int f = 1; for( int i = 0; a[i] != '\0' && b[i] != '\0'; i++ ) { if( a[i] == b[i] ) { if( f ) { if( a[i] >= 'A' && a[i] <= 'G' ) { printf( "%s ", week[a[i] - 'A'] ); f = 0; } } else { if( ( a[i] >= 'A' && a[i] <= 'N' ) || ( a[i] >= '0' && a[i] <= '9' ) ) { int num; if( a[i] >= '0' && a[i] <= '9' ) { num = a[i] - '0'; putchar( '0' ); } else num = a[i] - 'A' + 10; printf( "%d:", num ); break; } } } } for( int i = 0; c[i] !