在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 2 3 toupper 4 5 6 原型:extern int toupper(int c); 7 8 用法:#include <ctype.h> 9 10 功能:将字符c转换为大写英文字母 11 12 说明:如果c为小写英文字母,则返回对应的大写字母;否则返回原来的值。 13 14 举例: 15 16 17 // toupper.c 18 19 #include <syslib.h> 20 #include <ctype.h> 21 22 main() 23 { 24 char *s="Hello, World!"; 25 int i; 26 27 clrscr(); // clear screen 28 printf("%s\n",s); 29 for(i=0;i<strlen(s);i++) 30 { 31 putchar(toupper(s[i])); 32 } 33 34 getchar(); 35 return 0; 36 }
//---------------------------------1 #include <stdio.h> #include<stdlib.h> void main() { printf("0 & 0 is %d\n", 0 & 0); printf("0 & 1 is %d\n", 0 & 1); printf("1 & 1 is %d\n", 1 & 1); printf("1 & 2 is %d\n", 1 & 2); printf("15 & 127 is %d\n", 15 & 127); system("pause"); } //------------------------------2 #include <stdio.h> #include<stdlib.h> void main() { int value = 0xFF; printf("The inverse of %X is %X\n", value, ~value); system("pause"); } //-------------------------------3 #include <stdio.h> #include<stdlib.h> void main() { printf("0 | 0 is %d\n", 0 | 0); printf("0 | 1 is %d\n", 0 | 1); printf("1 | 1 is %d\n", 1 | 1); printf("1 | 2 is %d\n", 1 | 2); printf("128 | 127 is %d\n", 128 | 127); system("pause"); } //------------------------------------4 #include <stdio.h> #include<stdlib.h> void main() { printf("0 ^ 0 is %d\n", 0 ^ 0); printf("0 ^ 1 is %d\n", 0 ^ 1); printf("1 ^ 1 is %d\n", 1 ^ 1); printf("1 ^ 2 is %d\n", 1 ^ 2); printf("15 ^ 127 is %d\n", 15 ^ 127); system("pause"); } //------------------------------------5 #include <stdio.h> #include<stdlib.h> void main() { printf("The letter is %c\n", 'A'); printf("The letter is %c\n", 65); system("pause"); } //---------------------------------------6 #include <stdio.h> #include<stdlib.h> void main() { char letter; int vowel_count = 0; int consonant_count = 0; for (letter = 'A'; letter <= 'Z'; letter++) switch (letter) { case 'A': case 'E': case 'I': case 'O': case 'U': vowel_count++; break; default: consonant_count++; }; printf("The number of vowels is %d\n", vowel_count); printf("The number of vowels is %d\n", consonant_count); system("pause"); } //------------------------------------------------------------7 #include <stdio.h> #include <conio.h> #include <ctype.h> #include <stdlib.h> void main() { char letter; do { printf("A Display directory listing\n"); printf("B Display disk information\n"); printf("C Change system date\n"); printf("Q Quit\n"); printf("Choice: "); letter = getchar(); letter = toupper(letter); if (letter == 'A') system("DIR"); else if (letter == 'B') system("CHKDSK");//不能用 else if (letter == 'C') system("DATE"); } while (letter != 'Q'); system("pause"); }
|
请发表评论