A1061
字符串数组的对比。
如果使用char数组的话需要使用二维数组,因此混用string数组,需要#include<iostream>
判断string数组的长度:int len=str.length();
常用的ASCII码:
A-Z 65-90
a-z 79-122
0-9 48-57
空格 32 共95个字符:32-126
C++的输入输出太方便了= =
1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 int main(){ 5 string week[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"}; 6 string a,b,c,d; 7 int temp; 8 int count=0; 9 cin>>a>>b>>c>>d; 10 int len1=a.length(); 11 int len2=b.length(); 12 int len3=c.length(); 13 int len4=d.length(); 14 while(count<len1&&count<len2){ 15 if(a[count]==b[count]&&'A'<=a[count]&&a[count]<='G'){ 16 temp=a[count]-'A'; 17 break; 18 } 19 count++; 20 } 21 count+=1; 22 cout<<week[temp]<<' '; 23 while(count<len1&&count<len2){ 24 if(a[count]==b[count]){ 25 if('0'<=a[count]&&a[count]<='9'){ 26 temp=a[count]-'0'; 27 break; 28 } 29 else if('A'<=a[count]&&a[count]<='N'){ 30 temp=a[count]-'A'+10; 31 break; 32 } 33 } 34 count+=1; 35 } 36 count=0; 37 printf("%02d:",temp); 38 //以上应该没有问题 39 while(count<len3&&count<len4){ 40 if(c[count]==d[count]){ 41 if(('a'<=c[count]&&c[count]<='z')||('A'<=c[count]&&c[count]<='Z')){ 42 printf("%02d",count); 43 break; 44 } 45 } 46 count+=1; 47 } 48 return 0; 49 }