xiaoyurenwen 发表于 2020-7-11 00:21:50

今天终于爆肝把练习题程序写出来了;一个判断输入字符次数的小程序

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<math.h>
#include<cmath>

int main()
{
        int i = 0, a = 0, b = 0,q=0,w=0,e=0,r=0,t=0,y=0,u=0,l=0,o=0,p=0;
        char str;
        printf("please input :\n");
        gets_s(str);
        for (i = 0; i <= 9; i++)
        {
                if (' ' == str || '        ' == str)
                {
                        a = a + 1;
                }

                if ('0' == str || '1' == str || '2' == str || '3' == str || '4' == str || '5' == str || '6' == str || '7' == str || '8' == str || '9' == str)
                {
                        if ('0' == str)
                        {
                                q = q + 1;
                        }
                        if ('1' == str)
                        {
                                w = w + 1;
                        }
                        if ('2' == str)
                        {
                                e = e + 1;
                        }
                        if ('3' == str)
                        {
                                r = r + 1;
                        }
                        if ('4' == str)
                        {
                                t = t + 1;
                        }
                        if ('5' == str)
                        {
                                y = y + 1;
                        }
                        if ('6' == str)
                        {
                                u = u + 1;
                        }
                        if ('7' == str)
                        {
                                l = l + 1;
                        }
                        if ('8' == str)
                        {
                                o = 0 + 1;
                        }
                        if ('9' == str)
                        {
                                p = p + 1;
                        }
                }

                else
                {
                        b = b + 1;
                }
        }
       
                printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n", a, b-a,q,w,e,r,t,y,u,l,o,p);
                system("pause");
                return 0;
}

fhzzxxx 发表于 2020-7-11 09:11:34

恭喜!!!

xiaoyurenwen 发表于 2020-7-11 12:13:38

fhzzxxx 发表于 2020-7-11 09:11
恭喜!!!

{:5_108:}{:5_109:}

半亩鱼塘 发表于 2020-7-12 11:06:38

恭喜恭喜
页: [1]
查看完整版本: 今天终于爆肝把练习题程序写出来了;一个判断输入字符次数的小程序