#include <stdio.h> int lower(char a) { int b; b = (a >= 'A' && a <= 'Z') ? (a - 'A' + 'a') : a; return b; } int main() { int c; while((c = getchar()) != EOF && c != ' ') putchar(lower(c)); return 0; }
比较简单。
下面两行实用,使程序更好看。
printf("%3d%c",c[i],(i % 10 == 9 || i == 99) ? ' ' : ' '); printf("You have %d item%s. ",n,n == 1 ? "" : "s");