c語言代碼編程題匯總 :統計字串中的大寫和小寫字母的個數

來源:互聯網
上載者:User

標籤:功能   匯總   總結   strong   str   tin   get   print   stdio.h   

統計字串中的大寫和小寫字母的個數

  程式碼如下:

 

 1 /* 2     2017年3月6日19:42:21 3     功能:統計字串中的大寫和小寫字母的個數 4 */ 5  6 #include "stdio.h" 7 void fun (char *,int *,int *); 8  9 int main (void)10 {11     int m = 0,n = 0;12     int *Pm = &m, *Pn = &n;13     char s[100];14     printf ("請輸入一組字串:\n");15     gets(s);16     fun(s,Pm,Pn);17     printf("大寫字母的個數是%d\n小寫字母的個數是%d\n",n,m);18     return 0;19 }20 21 void fun(char *s,int *m,int *n)22 {    23     int i = -1;24     while(s[++i])25     {26         if(s[i] >= ‘a‘&&s[i] <= ‘z‘)27             (*m)++;28         else if(s[i] >= ‘A‘&&s[i] <= ‘Z‘)29             (*n)++;30         continue;31     }32     33 }34 /*35     總結:36     在VC++6.0中顯示的結果:37     ————————————————————————————38     請輸入一組字串:39     ASDFGzxcvb40     大寫字母的個數是541     小寫字母的個數是542     ————————————————————————————43 */44 45 46  

 

 

c語言代碼編程題匯總 :統計字串中的大寫和小寫字母的個數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.