C语言的简单滴俩问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:40:15
第一道题是:
允许输入一串字符串,然后统计这串字符串中,数字的个数,大写字母的个数和小写字母的个数。
第二题:
写一个函数,函数的作用是识别某个数是不是偶数,是偶数返回1,不是偶数返回0。

===============================
第一题:
void main()
{
int upcase=0,lowcase=0,number=0;
char buffer[10000];
char *p=buffer
gets(buffer)
for(;*p!='\0';p++)
{
if(*p>='a' && *p<='z') lowcase++;
if(*p>='A' && *p<='Z') upcase++;
if(*p>='0' && *p<='9') number++;
}
printf("upcase=%d",upcase);
printf("lowcase=%d",lowcase);
prinft("number=%d",number);
}

第二题:
int check(int num)
{
int re;
re=(num%2==0)? 1:0;
return re;

}

#include<stdio.h>
int main()
{
char a[100];
int number=0,xiaoxie=0,daxie=0,i;
scanf("%s",a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]>='0'