c语言初学者
编写一个程序
要求将输入的字母转化对应的12345
1条回答 默认 最新
_GX_ 2022-02-26 14:16关注#include <stdio.h> #include <ctype.h> #include <string.h> #define N 256 int main(int argc, char *argv[]) { char s[N], m[128] = {0}; if (argc != 2 || strlen(argv[1]) < 26) { printf("%s <26-letters>\n", argv[0]); return 1; } for (int i = 0; i < 26; i++) { m['a' + i] = tolower(argv[1][i]); m['A' + i] = toupper(argv[1][i]); } while (fgets(s, N, stdin)) { const char *p = s; while (*p) { if (isalpha(*p)) putchar(m[(int)*p]); else putchar(*p); p++; } } return 0; }$ gcc -Wall main.c $ ./a.out qwertyuiopasdfghjklzxcvbnm I was scared of dentists O vql leqktr gy rtfzolzl本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 1无用 1