22.8.29 C语言作业5道
作业:
1、从终端输入一个字符:如果是大写的 转换成小写,如果是小写的 转换成大写,如果是 0-9 按照 %d 输出对应整型的 0-9,其他字符 转换成 #并输出。
ubuntu@ubuntu:~/yuyu/yu/1/4$ cat 10.c
#if 0
1、从终端输入一个字符:
如果是大写的 转换成小写,
如果是小写的 转换成大写,
如果是 0-9按照 %d输出对应整型的0-9,
其他字符 转换成 #并输出。
#endif
#include <stdio.h>
int main(int argc, const char *argv[])
{char c;char b='#';scanf("%c",&c);if('c'<'Z'&&'c'>'A')printf("%c\n",(char)((int)c+32));else if('c'<'z'&&'c'>'a')printf("%c\n",(c-32));else if((int)'c'<10 && (int)'c'>=0)printf("%d\n",(int)c);elseprintf("%c\n",b);return 0;
}
ubuntu@ubuntu:~/yuyu/yu/1/4$
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
!
ubuntu@ubuntu:~/yuyu/yu/1/4$ B
B: command not found
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
C
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.outX
bash: ./a.outX: No such file or directory
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
X
8
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
!
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
a
A
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
^[[A^[[A^C
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
!
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
!
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
1ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
3ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
;ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
^[[A^[[A
�
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
@ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
/ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 11.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入字符:
A
a
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入字符:
a
A
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入字符:
/
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
!
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
A
a
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
、
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
2
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
10.c: In function ‘main’:
10.c:18:12: warning: multi-character character constant [-Wmultichar]else if(c<'10' && c>='0')^~~~
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
1
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
3
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
d
D
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ umask
0022
ubuntu@ubuntu:~/yuyu/yu/1/4$ ls -l
total 68
-rw-r--r-- 1 ubuntu ubuntu 543 11月 9 09:59 10.c
-rw-r--r-- 1 ubuntu ubuntu 679 11月 9 09:01 11.c
-rw-r--r-- 1 ubuntu ubuntu 411 11月 8 11:59 1.c
-rw-r--r-- 1 ubuntu ubuntu 0 11月 8 16:28 1.txt
-rw-r--r-- 1 ubuntu ubuntu 621 11月 8 13:59 2.c
-rw-r--r-- 1 ubuntu ubuntu 435 11月 8 14:47 3.c
-rw-r--r-- 1 ubuntu ubuntu 420 11月 8 17:19 4.c
-rw-r--r-- 1 ubuntu ubuntu 441 11月 8 16:24 5.c
-rw-r--r-- 1 ubuntu ubuntu 598 11月 8 17:07 6.c
-rw-r--r-- 1 ubuntu ubuntu 169 11月 8 17:06 7.c
-rw-r--r-- 1 ubuntu ubuntu 1305 11月 8 19:22 8.c
-rw-r--r-- 1 ubuntu ubuntu 546 11月 8 19:51 9.c
-rwxr-xr-x 1 ubuntu ubuntu 8400 11月 9 09:59 a.out
-rw-r--r-- 1 ubuntu ubuntu 16 11月 8 14:00 fwrite.c
-rw-r--r-- 1 ubuntu ubuntu 144 11月 8 19:57 time1.txt
-rw-r--r-- 1 ubuntu ubuntu 2398 11月 8 19:42 time.txt
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:A
a
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
49
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
50
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:0
48
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:48
52
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:90
57
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
2
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:10
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:11
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:12
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:22
2
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:,
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:k
K
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
2
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out2
bash: ./a.out2: No such file or directory
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out2
bash: ./a.out2: No such file or directory
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
2
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:9
9
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:10
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
10.c: In function ‘main’:
10.c:16:23: error: stray ‘\343’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:24: error: stray ‘\200’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:25: error: stray ‘\200’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:26: error: stray ‘\343’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:27: error: stray ‘\200’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:28: error: stray ‘\200’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:29: error: stray ‘\343’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
10.c:16:30: error: stray ‘\200’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
10.c:16:31: error: stray ‘\200’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
10.c: In function ‘main’:
10.c:16:23: error: stray ‘\343’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:24: error: stray ‘\200’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:25: error: stray ‘\200’ in programprintf("%c\n",c+32);��� //不能用'c',直接写c^
10.c:16:26: error: stray ‘\343’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:27: error: stray ‘\200’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:28: error: stray ‘\200’ in programprintf("%c\n",c+32); ��� //不能用'c',直接写c^
10.c:16:29: error: stray ‘\343’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
10.c:16:30: error: stray ‘\200’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
10.c:16:31: error: stray ‘\200’ in programprintf("%c\n",c+32); ���//不能用'c',直接写c^
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
49
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
50
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:0
48
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:0
0
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:A
a
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:a
A
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:.
#
ubuntu@ubuntu:~/yuyu/yu/1/4$ cat 10.c
#if 0
1、从终端输入一个字符:
如果是大写的 转换成小写,
如果是小写的 转换成大写,
如果是 0-9按照 %d输出对应整型的0-9,
其他字符 转换成 #并输出。
#endif
#include <stdio.h>
int main(int argc, const char *argv[])
{char c; //c=0,和c开头都可以char b='#';printf("请输入一个字符:");scanf("%c",&c);if(c<='Z'&&c>='A')printf("%c\n",c+32); //不能用'c',直接写celse if(c<='z'&&c>='a')printf("%c\n",c-32);else if(c<=57 && c>=48) //无法把c,变成整形,就让0和9变成字符{//int yu = c;printf("%d\n",c-48); //c-48可以,c竟然bu可以}elseprintf("%c\n",b);return 0;
}
ubuntu@ubuntu:~/yuyu/yu/1/4$
代码
#if 0
1、从终端输入一个字符:
如果是大写的 转换成小写,
如果是小写的 转换成大写,
如果是 0-9按照 %d输出对应整型的0-9,
其他字符 转换成 #并输出。
#endif
#include <stdio.h>
int main(int argc, const char *argv[])
{
char c; //c=0,和c开头都可以
char b='#';
printf("请输入一个字符:");
scanf("%c",&c);
if(c<='Z'&&c>='A')
printf("%c\n",c+32); //不能用'c',直接写c
else if(c<='z'&&c>='a')
printf("%c\n",c-32);
else if(c<=57 && c>=48) //无法把c,变成整形,就让0和9变成字符
{
//int yu = c;
printf("%d\n",c-48); //c-48可以,c竟然bu可以
}
else
printf("%c\n",b);
return 0;
}
结果
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
49
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:2
50
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:0
48
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 10.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:1
1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:0
0
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:A
a
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:a
A
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个字符:.
#
2、学生成绩管理
输入一个学生的成绩
[90,100] A
[80,90) B
[70,80) C
[60,70) D
[0,60) 不及格
其他 输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
12.c: In function ‘main’:
12.c:16:10: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘float *’ [-Wformat=]scanf("%d",&score);~^ ~~~~~~%e
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
12.c: In function ‘main’:
12.c:16:21: error: stray ‘\343’ in programscanf("%f",&score);��� //占位符还要我搜一下float->%f^
12.c:16:22: error: stray ‘\200’ in programscanf("%f",&score);��� //占位符还要我搜一下float->%f^
12.c:16:23: error: stray ‘\200’ in programscanf("%f",&score);��� //占位符还要我搜一下float->%f^
12.c:16:24: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:25: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:26: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:27: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:28: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:29: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:30: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:31: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:32: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:33: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:34: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:35: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:36: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:37: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:38: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:39: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:40: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:41: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:42: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:43: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:44: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:45: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:46: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:47: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:48: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:49: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:50: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:51: error: stray ‘\343’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:52: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:53: error: stray ‘\200’ in programscanf("%f",&score); ��� //占位符还要我搜一下float->%f^
12.c:16:54: error: stray ‘\343’ in programscanf("%f",&score); ���//占位符还要我搜一下float->%f^
12.c:16:55: error: stray ‘\200’ in programscanf("%f",&score); ���//占位符还要我搜一下float->%f^
12.c:16:56: error: stray ‘\200’ in programscanf("%f",&score); ���//占位符还要我搜一下float->%f^
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:90
A
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:l
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:2
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:.
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:2
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:c
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:.
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:/
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:.
不及格ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
12.c: In function ‘main’:
12.c:28:3: error: expected ‘(’ before ‘printf’printf("输入错误");^~~~~~
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:p
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:/
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:3
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:1
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩: 76
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:8^[[A
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:78
C
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:1
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:/
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
12.c: In function ‘main’:
12.c:30:27: error: stray ‘`’ in programprintf("输入错误2");`^
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:#
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:12
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:78
C
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:123
输入错误1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:/
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:-1
输入错误1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:./
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:12.1
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:888
输入错误1
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:^[[A^[[A^[[A^[[A
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ gcc 12.c
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:/
不及格
ubuntu@ubuntu:~/yuyu/yu/1/4$ ./a.out
请输入一个学生成绩:2334
输入错误
ubuntu@ubuntu:~/yuyu/yu/1/4$ 4
代码:
ubuntu@ubuntu:~/yuyu/yu/1/4$ cat 12.c
#if 02、学生成绩管理
输入一个学生的成绩
[90,100] A
[80,90) B
[70,80) C
[60,70) D
[0,60) 不及格
其他 输入错误
#endif
#include <stdio.h>
int main(int argc, const char *argv[])
{float score;printf("请输入一个学生成绩:");scanf("%f",&score); //占位符还要我搜一下float->%fif(score>=90&&score<=100)printf("A");else if(score>=80&&score<90)printf("B");else if(score>=70&&score<80)printf("C");else if(score>=60&&score<70)printf("D");else if(score>=0&&score<60)printf("不及格");else if(score<0||score>100) printf("输入错误");elseprintf("输入错误1"); //只能输入float 类型,要不然都会输出不及格putchar(10);return 0;
}
ubuntu@ubuntu:~/yuyu/yu/1/4$
3、输入一个年份 判断是平年还是闰年,闰年:能被4整除且不能被100整除 或者能被400整除,提示:整除: 没有余数 year%4==0,2000 闰年 2004 闰年 2022 平年 1900 平年
4、 输入一个三位数,判断是不是水仙花数,水仙花数(个位的三次方+十位的三次方+百位的三次方=数本身)
5、思考用算术求和和异或的方法实现两个数交换。
1、字母大小写运算
1.‘A’变'a'、'a'变'A':字符 ^= 32 ('A'^= 32 相当于 +32,'a' ^= 32 相当于 -32)
2.'A'变'a'、'A'变'a':字符 |= 32 ('A'|= 32 就相当于+32,'a' |= 32 不变)
3.'A'变'A'、'a'变'A':字符 &= ~32('A'&= 32 不变,'a' &= -32 相当于 -32)
'A' =65 'a'=97
1 0100 0001 A 65 ^ 0110 0001 a | 0110 0001 a &~32 0000 0001 A2 0110 0001 a 97 0100 0001 A 0110 0001 a 0010 0001 A 3 0010 0000 324 1101 1111 ~320010 0000 32
~ 5 0101 0100 84 T ^ 0111 0100 t | 0111 0100 t &~32 0101 0100 T
~ 6 0111 0100 116 t 0101 0100 T 0111 0100 t 0111 0100 T 同0异11.c [+] 2,22 All
-- INSERT --
递归按位输出
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
12345ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
1ubuntu@ubuntu:~/yuyu/yu/6/4$ gcc 3.c
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
1
1
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
12
12
ubuntu@ubuntu:~/yuyu/yu/6/4$ gcc 3.c
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
12
1 2
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
123
1 2 3
ubuntu@ubuntu:~/yuyu/yu/6/4$ ./a.out
123456789
1 2 3 4 5 6 7 8 9
ubuntu@ubuntu:~/yuyu/yu/6/4$ cat 3.c
#include <stdio.h>
int fun(int n)
{if(n<10&&n>0){printf("%d ",n);}else{fun(n/10);printf("%d ", n%10);}}
int main(int argc, const char *argv[])
{int n;scanf("%d",&n); fun(n);putchar(10);return 0;
}
ubuntu@ubuntu:~/yuyu/yu/6/4$
(4-3+4)%4第一圈没走完第二圈就被吃掉了余1
(4-4+2)%4第一圈走完剩下的就是多出来的,和走完一圈再走一圈一样
(max-front+tail)%MAX
二叉树分叉
先序先遍历到根再遍历到子树
先找先序或后序,根据中序判左右,用先后续排序
Makefile 创建
ubuntu@ubuntu:~/yuyu/yu/6/4$ cat makefile
OBJs+=px.o
OBJs+=zu.oall:px
px:$(OBJs)gcc $(OBJs) -o $@
px.o:px.cgcc -c $^ -o $@
zu.o:zu.cgcc -c $^ -o $@
clean:rm -r main.orm -r px.o
ubuntu@ubuntu:~/yuyu/yu/6/4$
v
总结:没有循环是常数阶,- -层循环线性阶,两层循环平方阶,成倍修改变量对数阶
总结:没有循环是常数阶,--层循环线性阶,两层循环平方阶
选择排序
\t 、 %3d
选择排序
快排:
IO的fopen fclose
ubuntu@ubuntu:~/yuyu/yu/1/3$ cat fopen.c
#include <stdio.h>
int main(int argc, const char *argv[])
{FILE *op = fopen("./1.c","w+");{if(NULL==op){printf("fopen failed\n");return 0;}printf("fopen success\n");}if(fclose(op)<0){printf("fclose failed\n");return -1;}printf("fclose success\n");return 0;
}
ubuntu@ubuntu:~/yuyu/yu/1/3$ gcc fopen.c
ubuntu@ubuntu:~/yuyu/yu/1/3$ ./a.out
fopen success
fclose success
ubuntu@ubuntu:~/yuyu/yu/1/3$
22.8.29 C语言作业5道相关推荐
- 单片机c语言 i%3c%3c1,单片机C语言作业及上机习题及答案
<单片机C语言作业及上机习题及答案>由会员分享,可在线阅读,更多相关<单片机C语言作业及上机习题及答案(37页珍藏版)>请在人人文库网上搜索. 1.第一次课熟悉winTC编译环 ...
- 搜索c语言作业答案的软件,吉林大学软件学院C语言作业参考答案.doc
吉林大学软件学院C语言作业参考答案 软件学院 高级语言程序设计作业参考答案 2010年12月 目录 第二章 简单程序1 第三章 分支程序设计3 第四章 循环程序设计9 第五章 模块化程序设计――函数1 ...
- C语言第十次作业,第十五次c语言作业.doc
<第十五次c语言作业.doc>由会员分享,可在线阅读,更多相关<第十五次c语言作业.doc(9页珍藏版)>请在人人文库网上搜索. 1.第十五次课作业:习题15-1:题码:章节: ...
- 代写python代码一般多少钱_代写CO 353课程作业、代做Python程序设计作业、代写Python语言作业...
代写CO 353课程作业.代做Python程序设计作业.代写Python语言作业 日期:2020-03-17 11:22 CO 353 - Homework assignment 4 Winter ' ...
- C语言及实验作业,C语言作业及参考答案
<C语言作业及参考答案>由会员分享,可在线阅读,更多相关<C语言作业及参考答案(65页珍藏版)>请在人人文库网上搜索. 1.C语言及实验作业参考做法分支程序设计上机作业:标题 ...
- 数组求fibnocci用c语言,c语言作业.docx
c语言作业.docx C语言_实验五.数组程序设计 13275016 刘勇一.实验目的1. 掌握一维数组的定义及初始化.2. 掌握一维数组元素的引用及其应用.二.实验设备Pc机.vc6.0二.实验内容 ...
- linux c语言常见面试题及答案,Linux下C语言的几道经典面试题小结(分享)
Linux下C语言的几道经典面试题小结(分享) 本篇文章整理了几道Linux下C语言的经典面试题,相信对大家更好的理解Linux下的C语言会有很大的帮助,欢迎大家探讨指正. 1.如果在Linux下使用 ...
- 计算机书籍-Go语言并发之道
Go语言并发之道 作者:[美]凯瑟琳(Katherine Cox-Buday) 出版社:中国电力出版社 出版时间:2018年12月
- 2016/06/22 中色启动筹码分析作业
2016/06/22 中色启动筹码分析作业--待核实 201 转载于:https://www.cnblogs.com/carl2380/p/5608596.html
最新文章
- JAVA 设计模式 模板方法模式
- HDU3037(卢卡斯定理)
- IOS开发:关于performSelectorXXX的延迟的使用
- yii2 js css,JS、CSS的引用
- 转:在 C# 中使用 P/Invoke 调用 Mupdf 函数库显示 PDF 文档
- Oracle 监听(Listener) 中 services 说明
- Check Dependency 2(一个检查.net部署文件完整性及一致性工具)
- 如何提高自己的工作效率
- Java使用Redis
- 当Java代码遇上抽象、重载加重写,一切都不美好了
- git获取特定的commit
- typescript step by step interface class
- docker 安装mysql_docker系列篇:docker以挂载配置文件和数据目录的方式安装mysql
- Linux运维之路怎么走?
- 使用apipost工具快速生成在线接口文档
- php 简易教学管理系统
- 移动计算为王——我眼中的下一代计算机产业
- java 设置字符串编码_Java字符编码设置总结
- python第六周项目华容道_华容道游戏(中)
- ffmpeg 多张图片合成h264编码格式的视频 按照指定时间截取 并添加 acc编码格式音乐 IOS可播放