文章检索
如何不用gets()函数完成. 算了,我照着图片抄上一遍吧但是,你直接复制粘贴,我直接复制粘贴不是更好?
sh-5.1$ ls
main.c
sh-5.1$ cat main.c
#include <stdio.h>
int main(void) {
size_t count = {0};
int ch;
while((ch = getchar()) != EOF) ++count;
size_t result = {0};
for(size_t i = 'A'; i <= 'Z'; ++i) result += count;
for(size_t i = 'a'; i <= 'z'; ++i) result += count;
for(size_t i = '0'; i <= '9'; ++i) result += count;
for(size_t i = 0; i <= 255; ++i) result += count;
result -= result + result + result + count[' '];
printf("%zu %zu %zu %zu %zu\n", result, result, result, count[' '], result);
return 0;
}
sh-5.1$ gcc -g -Wall -o main main.c
sh-5.1$ ls
mainmain.c
sh-5.1$ ./main
Nikon at the frontiers of science.
Flash(Adobe Flash Media Rights Management Server)
21.03,-0.87,-3.97%
8 62 10 10 14
sh-5.1$
发一下样例输入
要可以复制粘贴的那种 人造人 发表于 2022-11-17 23:35
发一下样例输入
要可以复制粘贴的那种
$ gcc -std=c99 test23.1.c && ./a.out
test23.1.c: 在函数‘main’中:
test23.1.c:8:5: 警告:不建议使用‘gets’(声明于 /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(str);
^
/tmp/cc1Is4My.o:在函数‘main’中:
test23.1.c:(.text+0x58): 警告:the `gets' function is dangerous and should not be used.
hamletroy 发表于 2022-11-17 23:41
$ gcc -std=c99 test23.1.c && ./a.out
test23.1.c: 在函数‘main’中:
test23.1.c:8:5: 警告:不建议 ...
? hamletroy 发表于 2022-11-17 23:41
$ gcc -std=c99 test23.1.c && ./a.out
test23.1.c: 在函数‘main’中:
test23.1.c:8:5: 警告:不建议 ...
把“Sample Input” 这个后面的框框里面的内容,复制粘贴上来
我需要复制粘贴那个框框里面的内容,用来测试程序
也就是说不算3个换行符
sh-5.1$ ls
main.c
sh-5.1$ cat main.c
#include <stdio.h>
int main(void) {
size_t count = {0};
int ch;
while((ch = getchar()) != EOF) ++count;
size_t result = {0};
for(size_t i = 'A'; i <= 'Z'; ++i) result += count;
for(size_t i = 'a'; i <= 'z'; ++i) result += count;
for(size_t i = '0'; i <= '9'; ++i) result += count;
for(size_t i = 0; i <= 255; ++i) result += count;
result -= result + result + result + count[' '] + 3;
printf("%zu %zu %zu %zu %zu\n", result, result, result, count[' '], result);
return 0;
}
sh-5.1$ gcc -g -Wall -o main main.c
sh-5.1$ ./main
Nikon at the frontiers of science.
Flash(Adobe Flash Media Rights Management Server)
21.03,-0.87,-3.97%
8 62 10 10 11
sh-5.1$
人造人 发表于 2022-11-17 23:57
算了,我照着图片抄上一遍吧
但是,你直接复制粘贴,我直接复制粘贴不是更好?
不好意思,我理解错了
页:
[1]