- 博客(25)
- 收藏
- 关注
原创 4.10例题
#include<stdio.h>int main(){ int x;char grade; printf("输入你的成绩:"); scanf("%d",&x); switch((int)x/10) { case 10: case 9: printf("你的等级为A"); break; case 8: printf("...
2022-04-10 12:09:17
226
原创 4.9例题
#include<stdio.h>int main(){ int a,b,c,t; scanf("%d,%d,%d",&a,&b,&c); if(a>b) {t=a;a=b;b=t;} if(a>c) {t=a;a=c;c=t;} if(b>c) {t=b;b=c;c=t;} printf("%d,%d,%d\n",a,b,c); return 0;}...
2022-04-09 11:27:56
209
原创 4.8例题
#include<stdio.h>int main(){ int x;char grade; printf("输入你的成绩:"); scanf("%d",x); if(x>90) grade='A'; printf("你的等级为A"); if(x>=80&&x<=89) printf("你的等级为B"); grade='B'; if(x>=70&&x&l...
2022-04-08 12:03:41
167
原创 4.7例题
#include<stdio.h>int main(){ int x;float y; printf("输入x的值:"); scanf("%d",&x); if(x<1) y=x; else if(x>=1&&x<10) y=2*x-1; else y=3*x-11; printf("y=%0.6f\n",y); return 0;}...
2022-04-07 21:23:55
106
原创 4.6例题
#include<stdio.h>int main(){ int i = 5; do { if(i%3==1) if (i % 5 == 2) { printf("%d", i); break; } i++; } while (i != 0); return 0;}...
2022-04-06 12:00:55
46
原创 4.5例题
#include<stdio.h>int main(){ int i, flag, number; printf("请输入一个正整数:"); scanf("%d", &number); flag = 1; for (i = 2, i <= number - 1 && flag; i++); if (number % i == 0) flag = 0; if (flag) pr...
2022-04-05 08:40:43
187
原创 4.4例题
#include<stdio.h>int main(){ int i; float x, max; printf("请输入第一个数:"); scanf("%f", &x); max = x; for (i = 1; i <= 9, i++) { printf("请输入第%d个数:", i++); scanf("%f", &x); if (x > max)...
2022-04-04 12:06:12
270
原创 4.3例题
#include<stdio.h>#include<nath.h>int main(){ int n = 13, year; double number, rate = 0.02; for (year = 1; year <= 10, year++) { number = n * pow((1 + rate), year); printf("%2年后,人数为:%.2f亿\n", year, number);...
2022-04-03 17:14:22
414
原创 4.2例题
#include<stdio.h>int main(){ int year, leap; printf("输入年份:"); scanf("%d", &year); if (year % 4! = 0) leap = 0; elae if (year % 100 != 0) leap = 1; else if (year % 400 != 0) leap = 0; else ...
2022-04-02 13:55:08
230
原创 4.1例题
#include<stdio.h>int main(){ int n, a, b, c; printf("请输入一个3位整数:"); scanf("%d", &n); if (n < 100 || n>999) printf("输入错误!\n"); else { a = n / 100; b = n / 10 % 10; c = n % 10; ...
2022-04-01 21:06:52
66
原创 3.31例题
#include<stdio.h>int main(){ int month; printf("输入月份:"); scanf("%d", &month); switch ((month - 1) / 3); { case 0: printf("%d月是第一季度\n", month); break; case 1: printf("%d月是第二季度\n", month);...
2022-03-31 12:49:56
53
原创 3.30例题
#include<stdio.h>int main(){ int x, y; scanf("%d", &x); if (x > 0) y = 1; else if (x == 0) y = 0; else y = -1; printf("y=%d\n", y); return 0;}...
2022-03-30 12:26:43
65
原创 3.29例题
import requestsfrom lxml import htmlurl='https://movie.douban.com/' #需要爬数据的网址page=requests.Session().get(url)tree=html.fromstring(page.text)result=tree.xpath('//td[@class="title"]//a/text()')
2022-03-29 23:09:14
281
原创 3.27实数排序
#include<stdio.h>int main() { float a, b, c, t; scanf("%f,%f,%f", &a, &b, &c); if(a>b) { t = a; a = b; b = t; } if (a > c) { t = a; a = c; c = t; } if (b > c) { t =...
2022-03-27 21:10:11
261
原创 3.26练习
#include<stdio.h>#include<math.h>int main(){ double x, y; printf("输入x的值:"); scanf("%if", &x); if (x < 1) y = exp(x); else y = pow(x, 2) - 1; printf("f(%f)=%.2f\n", x, y); return 0;}...
2022-03-26 14:58:50
322
原创 2.25 逻辑运算
#include<stdio.h>int main(){ int a = 3, b = 3, c = 2, d; printf("%d,", !a && !b && c); printf("%d,", !a || !b || c); printf("%d\n", a >= b && b > c); d = c-- || (b = 6) && a++; printf("a...
2022-03-25 18:35:27
54
原创 3.25 贪吃蛇
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数enum DIR{ UP, DOWN, LEFT, RIGHT,};struct Snake{ int size; int dir; int speed; POINT coor[SN...
2022-03-24 22:02:00
71
原创 贪吃蛇加入暂停
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数enum DIR{ UP, DOWN, LEFT, RIGHT,};struct Snake{ int size; int dir; int speed; POINT coor[SN...
2022-03-23 18:54:28
197
原创 贪吃蛇食物刷新
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数enum DIR{ UP, DOWN, LEFT, RIGHT,};struct Snake{ int size; int dir; int speed; POINT coor[SN...
2022-03-22 22:19:32
123
原创 贪吃蛇食物
#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数enum DIR{ UP, DOWN, LEFT, RIGHT,};struct Snake{ int size; int dir; int speed; POINT coor[SN...
2022-03-21 22:33:15
64
原创 贪吃蛇边界
#include<stdio.h>#include<conio.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数enum DIR{ UP, DOWN, LEFT, RIGHT,};struct Snake{ int size; int dir; int speed; POINT coor[SNAKE_NUM];}snake;void Ga...
2022-03-20 23:02:43
102
原创 贪吃蛇上色
#include<stdio.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数struct Snake{ int size; int dir; int speed; POINT coor[SNAKE_NUM];}snake;void GameInit(){ initgraph(640, 480); snake.size = 3; snake.speed = 10;...
2022-03-19 22:08:11
260
原创 贪吃蛇头部
#include<stdio.h>#include<graphics.h>#define SNAKE_NUM 500//蛇最大节数struct Snake{ int size; int dir; int speed; POINT coor[SNAKE_NUM];}snake;void GameInit(){ initgraph(640, 480); snake.size = 0; snake.speed = 10;...
2022-03-18 23:08:47
118
原创 2.13
#include<stdio.h>int main(){int number,a,b,c; number=123; printf("输入的三位数为:%d\n",number); a=number/100; b=(number-a*100)/10; c=number%10; printf("反序数是:%d%d%d\n",c,b,a); return 0;}
2022-03-17 21:59:27
315
原创 顺序结构程序设计
#include<stdio.h>int main(void){ int celsius,fahr; printf("输入华氏温度:"); scanf("%d",&fahr) ; celsius=5*(fahr-32)/9; printf("华氏温度为:%d,摄氏温度为:%d\n",fahr,celsius); return 0;}...
2022-03-16 22:25:29
32
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人