標籤:ring while stdio.h res c語言 int 字母 inpu dsd
將字串中的大寫字母轉換成小寫字母
程式碼如下:
1 /* 2 2017年3月8日21:21:46 3 功能:將字串中的大寫字母轉換成小寫字母 4 */ 5 /* 6 #include"stdio.h" 7 8 int main() 9 {10 int n = 0;11 12 char a[100];13 14 printf("please input a string:");15 16 gets(a);17 18 for(int i = 0 ;a[i] != ‘\0‘;i++)19 {20 21 n++;22 23 }24 25 for(int j = 0;j < n ; j++)26 {27 28 if (a[j] >= ‘A‘&& a[j] <= ‘Z‘)29 {30 31 a[j] = a[j] + 32;32 33 }34 35 }36 37 puts(a);38 39 }*/40 41 #include"stdio.h"42 43 int main()44 {45 char a[100];46 47 char *p = a;48 49 printf("please input a string: \n");50 51 gets(a);52 53 while(*p)54 {55 56 if(*p >= ‘A‘&& *p <= ‘Z‘)57 {58 59 *p = *p + 32;60 61 }62 63 p++;64 65 }66 printf("the result is: \n");67 puts(a);68 }69 /*70 總結:71 在VC++6.0中顯示的結果:72 ——————————————————————————————73 please input a string:74 ASDsdffgj75 the result is:76 asdsdffgj77 ——————————————————————————————78 */
c語言代碼編程題匯總:將字串中的大寫字母轉換成小寫字母