水一篇文章—-
很简单:)
关键点:
3.可使用malloc语句为字符数组进行动态内存分配
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <stdio.h> #include <stdlib.h> #include <string.h>
int main() { int i = 0; printf("please input:\n"); char str[100]; fgets(str, sizeof(str), stdin); while (str[i + 1]) { if ((str[i] <= 'c' && str[i] >= 'a') || (str[i] <= 'C' && str[i] >= 'A')) { str[i] = str[i] + 23; printf("%c", str[i]); } else if ((str[i] >= 'd' && str[i] <= 'z') || (str[i] >= 'D' && str[i] <= 'Z')) { printf("%c", str[i] - 3); } i++; if (str[i] == (char)"\n") { break; } } return 0; }
|