私信TA

用户名:chenqi

访问量:33880

签 名:

等  级
排  名 356
经  验 5107
参赛次数 0
文章发表 52
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

#include<stdio.h>
#include<string.h>
int count[100];//注意该变量定义为全局变量,保存各种字符的个数;
int* Count(char *s)
{
 int i,char_count=0,num_count=0,k_count=0,other_count=0;
 
 for(i=0;*(s+i)!='\0';i++)
 {
  //printf("%c ",*(s+i));
  if((*(s+i)>='a'&&*(s+i)<='z')||(*(s+i)>='A'&&*(s+i)<='Z'))
   count[0] = ++char_count; //注意前++与后++的区别
  if(*(s+i)>='0'&&*(s+i)<='9')
   count[1] = ++num_count;
  if(*(s+i)==' ')
   count[2] = ++k_count;
 }
 other_count = i-char_count-num_count-k_count;
 count[3] = other_count;
 return count;
}
int main()
{
 int i,*ptr;
 char s[100];
 gets(s);
 ptr = Count(s);
 for(i=0;i<4;i++)
 {
  printf("%d ",*(ptr+i));
 }
 return 0;
}
 

0.0分

0 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区