hdu 1048 The Hardest Problem Ever(水题,stcmp)

小记:我用strcmp来处理是START还是END,还是是ENDOFINPUT


思路:输出用(s[i]-'A+21)%26.即装换了过来。


代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char s[1010];

int main() {
    int n, m, k;
    while(gets(s)) {
        if(strcmp(s,"ENDOFINPUT") == 0)break;
        if(strcmp(s,"START") == 0) {
            while(gets(s)) {
                if(strcmp(s,"END") == 0)break;
                for(int i = 0; i < strlen(s); ++i) {
                    if(s[i] >= 'A' && s[i] <= 'Z') {
                        printf("%c",(s[i] - 'A' +21)%26 + 'A');
                    } else
                        printf("%c",s[i]);
                }
                printf("\n");
            }
        }
    }
    return 0;
}


你可能感兴趣的:(hdu 1048 The Hardest Problem Ever(水题,stcmp))