#includeint main(){ int c, q = 1; while ((c = getchar()) != EOF) {//用getchar()可以边读取边处理 if (c == '"') { printf("%s", q ? "“" : "”"); q = !q; } else printf("%c", c); } return 0;}
#include "stdafx.h"#includechar s[] = "`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";//注意“\\”给\转义int main(){ char c; int i; while ((c = getchar()) != EOF) { for (i = 1; s[i] && s[i] != c; i++); if (s[i]) putchar(s[i - 1]); else putchar(c); }}
测试
#includechar s[] = "abc";int i[] = { 1,2,3 };int main(){ printf("%d\n", i[3]); printf("%d\n", s[3]); printf("%c\n", s[3]); if (s[2]) printf("%s", "success"); if (s[3])printf("%s", "faile");}