C语言-8
来源:互联网 发布:人工智能的伦理困境 编辑:程序博客网 时间:2024/06/06 20:17
struct Size{ int width; int height;};void equalWidth(struct Size s1,struct Size s2);void equalWidth(struct Size s1,struct Size s2){ if (s1.width == s2.width) { printf("等宽\n"); }else printf("不等宽\n");}void equalHeight(struct Size s1,struct Size s2);void equalHeight(struct Size s1,struct Size s2){ if (s1.height == s2.height) { printf("等高\n"); }else printf("不等高\n");}void equalsize(struct Size s1,struct Size s2);void equalsize(struct Size s1,struct Size s2){ if (s1.height == s2.height && s1.width == s2.width) { printf("相等\n"); }else printf("不相等\n");}struct point{ int x; int y;};void equalX (struct point p1,struct point p2);void equalX (struct point p1,struct point p2){ if (p1.x == p2.x) { printf("同一水平线\n"); }else printf("不在同一水平线\n");}void equalY (struct point p1,struct point p2);void equalY (struct point p1,struct point p2){ if (p1.y == p2.y) { printf("同一垂直线\n"); }else printf("不在同一垂直线\n");}void equalXY (struct point p1,struct point p2);void equalXY (struct point p1,struct point p2){ if (p1.y == p2.y && p1.x == p2.x) { printf("两个点相等\n"); }else printf("两个点不等\n");}typedef struct score{ int num; char name[20]; float math; float english; float c;}Score;void aveEvery(Score s1[],int count);void aveEvery(Score s1[],int count){ float totalC = 0,totalM = 0,totalE = 0; for (int i = 0; i < count; i++) { totalC += s1[i].c; totalM += s1[i].math; totalE += s1[i].english; } printf("c的平均分是:%.2f math的平均分是:%.2f English的平均分是:%.2f \n",totalC/count,totalM/count,totalE/count);}void twoScore(Score s1[],int count);void twoScore(Score s1[],int count){ for (int i = 0; i < count; i++) { if (s1[i].c < 60 && s1[i].math < 60 && s1[i].english < 60) { printf("学号是:%d c成绩是:%.2f math成绩是:%.2f english成绩是:%.2f\n",s1[i].num,s1[i].c,s1[i].math,s1[i].english); }else { if (s1[i].c < 60 && s1[i].math < 60 ) { printf("学号是:%d c成绩是:%.2f math成绩是:%.2f\n",s1[i].num,s1[i].c,s1[i].math); } if (s1[i].c < 60 && s1[i].english < 60) { printf("学号是:%d c成绩是:%.2f english成绩是:%.2f\n",s1[i].num,s1[i].c,s1[i].english); } if (s1[i].math < 60 && s1[i].english < 60 ) { printf("学号是:%d english成绩是:%.2f math成绩是:%.2f\n",s1[i].num,s1[i].english,s1[i].math); } } }}void goodStudent(Score s1[],int count);void goodStudent(Score s1[],int count){ for (int i = 0; i < count; i++) { float ave =( s1[i].c + s1[i].math +s1[i].english ) / 3; if (ave >= 85 && ave <= 90) { printf("三门课平均成绩在 85-90 分的学生学号为:%d 姓名为:%s",s1[i].num,s1[i].name); } }}int main(int argc, const char * argv[]){// struct Size s1 = {2,5};// struct Size s2 = {5,5};// equalWidth(s1, s2);// equalHeight(s1,s2);// equalsize(s1,s2); // struct point p1 = {7, 8};// struct point p2 = {7, 8};// equalX(p1, p2);// equalY(p1, p2);// equalXY(p1, p2); Score s1 = {1,"黑猫",89,87,88}; Score s2 = {2,"白猫",64,57,88}; Score s3 = {3,"花猫",64,47,48}; Score s4 = {4,"格子猫",24,47,48}; Score s5 = {5,"长毛猫",99,77,95}; Score student[5] = {s1,s2,s3,s4,s5}; aveEvery(student, 5); twoScore(student, 5); goodStudent(student, 5); return 0;}
0 0
- C语言例题8:
- c语言练习8
- c语言思想8
- C语言 8进制
- C语言-8
- C语言整理-8
- C语言学习8
- C语言8
- C语言练习题(8)
- C语言入门——C语言学习日志8
- C语言学习笔记(8)
- 孔乙己学c语言(8)
- C语言学习笔记8
- C语言学习笔记8
- 明解C语言1-8
- 二级C语言复习8
- C语言练习12-8
- C语言复习笔记 8
- C语言-7
- ZJU 2562 More Divisors (反素数)
- Android如何防止apk程序被反编译
- 从输入 URL 到页面加载完的过程中都发生了什么事情?
- Java实现单链表的一些常用操作
- C语言-8
- Python - 2
- 利用const_cast进行类型转换
- 快照与AMI的区别
- 迭代(遍历)时候不可以使用集合的remove和add方法,但可使用Java迭代器的remove和add方法
- 05-图2. Saving James Bond - Easy Version (25)
- 在 Eclipse 下利用 gradle 构建系统
- C语言-9
- jquery小技巧