牛客网_PAT乙级1004_福尔摩斯的约会 (20)
生活随笔
收集整理的這篇文章主要介紹了
牛客网_PAT乙级1004_福尔摩斯的约会 (20)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{char a[4][100];int i;//第i個字符串int size_1, size_2, size_3, size_4;int size_max, size_max34;int compare;char same_alpha_1_2;int flag = 0;char same_char_1_2;int same_num = 0;for (i = 0; i < 4; i++){scanf("%s", a[i]);}//找前兩個字符串第一對相同的大寫英文字母size_1 = strlen(a[0]);size_2 = strlen(a[1]);size_max = (size_1 > size_2 ? size_1 : size_2);for (compare = 0; compare < size_max; compare++){if (a[0][compare] == a[1][compare] && a[0][compare] >= 'A'&&a[0][compare] <= 'Z'){same_alpha_1_2 = a[0][compare];break;}}if (same_alpha_1_2 == 'A')printf("MON");else if (same_alpha_1_2 == 'B')printf("TUE");else if (same_alpha_1_2 == 'C')printf("WED");else if (same_alpha_1_2 == 'D')printf("THU");else if (same_alpha_1_2 == 'E')printf("FRI");else if (same_alpha_1_2 == 'F')printf("SAT");else if (same_alpha_1_2 == 'G')printf("SUN");printf(" ");//第二對相同的字符for (; compare < size_max; compare++){if (a[0][compare] == a[1][compare]){if (flag == 1){same_char_1_2 = a[0][compare];break;}else{flag = 1;continue;}}}if (same_char_1_2 >= '0'&&same_char_1_2 <= '9'){if (same_char_1_2 < '10')printf("0");printf("%c", same_char_1_2);}else{if (same_char_1_2 == 'A')printf("10");else if (same_char_1_2 == 'B')printf("11");else if (same_char_1_2 == 'C')printf("12");else if (same_char_1_2 == 'D')printf("13");else if (same_char_1_2 == 'E')printf("14");else if (same_char_1_2 == 'F')printf("15");else if (same_char_1_2 == 'G')printf("16");else if (same_char_1_2 == 'H')printf("17");else if (same_char_1_2 == 'I')printf("18");else if (same_char_1_2 == 'J')printf("19");else if (same_char_1_2 == 'K')printf("20");else if (same_char_1_2 == 'L')printf("21");else if (same_char_1_2 == 'M')printf("22");else if (same_char_1_2 == 'N')printf("23");}printf(":");//第一對相同字母size_3 = strlen(a[2]);size_4 = strlen(a[3]);size_max34 = (size_3 > size_4 ? size_3 : size_4);int alpha=0;for (compare = 0; compare < size_max; compare++){if ((a[2][compare] >= 'A'&&a[3][compare] <= 'Z') || (a[2][compare] >= 'a'&&a[3][compare] <= 'z')){alpha++;}if (a[2][compare] == a[3][compare] && ((a[2][compare] >= 'A'&&a[3][compare] <= 'Z') || (a[2][compare] >= 'a'&&a[3][compare] <='z'))){same_num = alpha;break;}}if (same_num < 10)printf("0");printf("%d", same_num);system("pause");
}
總結
以上是生活随笔為你收集整理的牛客网_PAT乙级1004_福尔摩斯的约会 (20)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 牛客网_PAT乙级1002_数字分类 (
- 下一篇: 关于牛客网运行超时的原因分析