/ 科创班 /

记录详情

Accepted

/in/foo.c: In function 'main':
/in/foo.c:13:1: warning: 'gets' is deprecated [-Wdeprecated-declarations]
 gets(text);
 ^~~~
In file included from /in/foo.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cc6xxlns.o: In function `main':
foo.c:(.text.startup+0x9): warning: the `gets' function is dangerous and should not be used.
# 状态 耗时 内存占用
#1 Accepted 2ms 256.0 KiB
#2 Accepted 1ms 256.0 KiB
#3 Accepted 2ms 256.0 KiB
#4 Accepted 1ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 6ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB
#8 Accepted 2ms 256.0 KiB
#9 Accepted 2ms 256.0 KiB
#10 Accepted 2ms 256.0 KiB

代码

#include<stdio.h>

int letter,digit,space,others;

int main()
{
void count(char []);

char text[80];

//printf("input string:\n");

gets(text);
//printf("string:");

//puts(text);

letter=0;
digit=0;
space=0;
others=0;

count(text);
printf("%d\n%d\n%d\n%d",letter,digit,space,others);
//printf("\nletter:%d\ndigit:%d\nspace:%d\nothers:%d\n",letter,digit,space,others);
return 0;
}

void count(char str[])
{
int i;
for(i=0;str[i]!='\0';i++)
    if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))
       letter++;
    else if(str[i]>='0'&&str[i]<='9')
       digit++;
    else if(str[i]==32)
       space++;
    else
       others++;
}

信息

递交者
类型
递交
题目
7.9统计个数
题目数据
下载
语言
C
递交时间
2018-07-13 16:54:58
评测时间
2018-07-13 16:54:58
评测机
分数
100
总耗时
29ms
峰值内存
256.0 KiB