标签:ret str1 printf cin space length style ring htable
题意有点不明不白。
注意点:字符间的比较是在同一下标进行的(不然测试点1,4过不了)。
#include"iostream" #include"cctype" using namespace std; string hashtable1[7] = {"MON ","TUE ","WED ","THU ","FRI ","SAT ","SUN "}; int main() { string str1,str2,str3,str4; cin>>str1>>str2>>str3>>str4; int len = str1.length() < str2.length()?str1.length():str2.length(),flag = 0; for(int i = 0; i < len; ++i) { if(str1[i] == str2[i] && str1[i]>=‘A‘&&str1[i] <=‘G‘&&flag == 0) { cout<<hashtable1[str1[i]-‘A‘]; flag = 1; continue; } if(flag == 1 && str1[i] == str2[i] && ((isdigit(str1[i]))||(str1[i]>=‘A‘&& str1[i] <=‘N‘)) ) { printf("%02d:",isdigit(str1[i])?str1[i]-‘0‘:str1[i]-‘A‘+10); break; } } len = str3.length() < str4.length()?str3.length():str4.length(); for(int i = 0; i < len; ++i) { if(isalpha(str3[i]) && str3[i] == str4[i]) { printf("%02d",i); break; } } return 0; }
标签:ret str1 printf cin space length style ring htable
原文地址:https://www.cnblogs.com/keep23456/p/12313828.html