fighter


私信TA

用户名:liuyifan

访问量:14637

签 名:

就一普通靓女

等  级
排  名 1652
经  验 2634
参赛次数 1
文章发表 38
年  龄 20
在职情况 学生
学  校 HNNU
专  业 计算机类

  自我简介:

就一普通靓女

 

0.0分

74 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<stdio.h>
int main()
{
    char c;
    int word=0,digits=0,other=0,space=0;
    c=getchar();
    while(c!='\n')
    {
         if((c>='a'&& c<='z')||((c>='A'&& c<='Z'))
         {
            word++;
        }
         else if(c>='0'&&c<='9')
        {
            digits++;
        }
        else if (c==' ')
        {
             space++;
        }
        else
        {
              other++;
        }
        c=getchar();
    }
    printf("%d,%d,%d,%d",word,digits,space,other);
    return 0;
}
有什么问题吗求大佬告知不知道为什么出错了
2024-04-17 22:34:52
#include<stdio.h>
#include<string.h>
#include<process.h>
int main()
{
	char str[100];
	int a=0,c=0,d=0,e=0;
	printf("请输入一行字符:");
	fgets(str,100,stdin);
	 for(int i=0;str[i]!='\0';i++){	
	 	if((str[i]>'A'&&str[i]<'Z')||(str[i]>'a'&&str[i]<'z')){
	 		a++;}
		 else if(str[i]>='0'&&str[i]<='9'){
		 	c++;
		 }
		 else if(str[i]==' '){
		 	d++;
		 } 
		 else{
		 	e++;
		 } 
		}
	 printf("英文字母有%d个,数字有%d个,空格有%d个,其他字符有%d个",a,c,d,e);
	 return 0;
}
请问我这个按照样例输出时,为什么那个英文字符只有19个,而其他字符有9个啊
2023-05-15 23:57:07
#include<iostream>
using namespace std;
string n;
int a,b,c,d;
int main()
{
    getline(cin,n);
    for(int i=0;i<n.size();i++)
    {
        if((n[i]>64 && n[i]<122) || n[i]==64 || n[i]==122)a++;
        else if((n[i]>48 && n[i]<58) || n[i]==48 || n[i]==58)b++;
        else if(n[i]==32)c++;
        else d++;
    }
    cout<<a<<" "<<b<<" "<<c<<" "<<d;
    return 0;
}
这个办法只有50分,麻烦各位帮我看看谢谢
2023-04-19 17:52:28
#include<stdio.h>
#include<string.h>
int main()
{
	char a[200];
	int i,m=0,n=0,k=0,j=0;
	gets(a);
	for(i=0;i<strlen(a);i++)
	{
		if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
		{
			m++;
		}
		else if(a[i]>='0'&&a[i]<='9')
		{
			n++;
		}
		else if(a[i]==' ')
		{
			k++;
		}
		else
		{
			j++;
		}
		printf("%d %d %d %d",m,n,j,k);
	}
	return 0;
}
请问我这个为啥是错的?
2023-03-21 23:53:32
#include<stdio.h>
#include<string.h>
#define N 200
int main(void)
{
	char str[N];
	gets(str);
	int i;
	int a=0,b=0,c=0,d=0;
	for(i=0; i<strlen(str); i++)
	{
		if(str[i]>='0'&&str[i]<='9')
		{
			a++;	
		}
		else if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z')
		{
			b++;
		}
		else if(str[i]==' ')
		{
			c++;
		}
		else
		{
			d++;
		}
	}
	printf("%d %d %d %d\n",a,b,c,d);
	return 0;
 }
2023-02-25 00:08:48
#include<stdio.h>
#include<string.h>

int main()
{
	int i,h=0,j=0,k=0,p=0;
	char str[100];
    gets(str);
    int l=strlen(str);
	for(i=0;i<l;i++)
	{
		if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z')
		{
			j++;
		}
		else if(str[i]==' ')
		{
			k++;
		}
		else if(str[i]>='0'&&str[i]<='9')
		{
			h++;
		}
		else
		{
			p++;
		}
	}
	printf("字母:%d\n空格:%d\n数字:%d\n其他字符:%d\n",j,k,h,p);
	return 0;
}
谁可以指点我一下
2023-02-08 20:12:00
成功了!
int zm = 0, sz = 0, kg = 0, qt = 0, i = 0;
char str[100];
gets(str);
while (i < strlen(str))
{
	if (str[i] >= 'a' && str[i] <= 'z' || str[i] >= 'A' && str[i] <= 'Z')
	{
		zm++;
	}
	else if (str[i] >= '0' && str[i] <= '9')
	{
		sz  ++;
	}
	else if (str[i] == ' ')
	{
		kg ++;
	}
	else
	{
		qt ++;
	}
	i ++;
}
printf("%d %d %d %d", zm, sz, kg, qt);
	return 0;
2023-01-07 17:48:17
#include<string.h>
int main()
{
	char str[200];
	int i,n,letter=0,space=0,number=0,other;
	gets(str);
	n=strlen(str);
	for(i=0;i<=n;i++)
	{	
	if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z')
	letter++; 
	else if(str[i]==' ')
	space++;
	else if(str[i]>='0'&&str[i]<='9')
	number++;
	else
            other++;
	}
	
    printf("%d %d %d %d",letter,space,number,other);
    return 0;	
}
谁能指出错误,非常感谢!!!
2023-01-06 13:06:22