#include <stdio.h> /**********found**********/ ___1___ fun(char ch) { /**********found**********/ if (ch>='0' && ___2___) /**********found**********/ return '9'- (ch-___3___); return ch ; } main() { char c1, c2; printf("\nThe result :\n"); c1='2'; c2 = fun(c1); printf("c1=%c c2=%c\n", c1, c2); c1='8'; c2 = fun(c1); printf("c1=%c c2=%c\n", c1, c2); c1='a'; c2 = fun(c1); printf("c1=%c c2=%c\n", c1, c2); }
时间: 2023-08-21 15:06:09 浏览: 126
#include<stdio.h>
#include <stdio.h>
char fun(char ch) {
if (ch>='0' && ch<='9')
return '9' - (ch-'0');
return ch;
}
int main() {
char c1, c2;
printf("\nThe result :\n");
c1='2';
c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
c1='8';
c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
c1='a';
c2 = fun(c1);
printf("c1=%c c2=%c\n", c1, c2);
return 0;
}
这段代码的功能是将 ASCII 码为 '0' 到 '9' 的字符翻转,即 '0' 变成 '9','1' 变成 '8','2' 变成 '7',以此类推,其余字符不变。
阅读全文