结构
来源:互联网 发布:nginx源码 编辑:程序博客网 时间:2024/04/30 03:41
#include<stdio.h>#include<string.h>struct student{ int num; //学号 char name[8]; //姓名 float score; //成绩};//根据学生姓名返回学生信息struct student search(struct student *s,char *name){ struct student temp; temp.num=0; //若查找失败,学号置0. strcpy(temp.name,"null"); //若查找失败,姓名置null. temp.score=0.0; //若查找失败,成绩置0.0 int i; for(i=0;i<3;i++) { if(strcmp(name,s[i].name)==0) //若查找成功,重置学生信息。 temp=s[i]; } return temp; //返回学生信息}main(){ //对结构体数组初始化 struct student stu[3]={{1001,"张三",98},{1002,"李四",85},{1003,"王五",74}}; struct student h; char name[8]; printf("请输入查找的姓名:"); scanf("%s",name); h=search(stu,name); printf("num=%d,name=%s,score=%.1f",h.num,h.name,h.score);}
阅读全文
0 0
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 结构
- 获取手机号运营商及归属地的免费API
- table行的折叠和展开
- $.each 循环json以及JSON.parse() JSON.stringify() jQuery.parseJSON()的用法:
- 机器学习之线性回归python实现
- 使用adb调试串口
- 结构
- javascript数据结构系列(六)-二叉树(2)
- Linux使用Nexus搭建Maven私服
- angular-select显示数组案例
- Git 官方教程 --NAME gittutorial-2
- 人人都可以做深度学习应用:入门篇(下)
- 解决 swiper 在angularjs中使用循环轮播失效的问题
- 消息队列mq总结
- java项目中附件的上传下载