一个简单的结构体例题
来源:互联网 发布:nsis error修复软件 编辑:程序博客网 时间:2024/05/08 01:01
#include<stdio.h> #include<stdlib.h> #include<string.h> struct STI { char id[9]; char name[17]; char sex; char age; float score; }; int inutStudentInformation(struct STI *st,int maxCount); //struct STI *st = stu1; void showAllStudentInformation(struct STI *s,int count); void showOneStudentInformation(struct STI stu); void showOneStudentInformation(struct STI stu) { printf("%8s %-16s %4s %4d %f\n", stu.id,stu.name,stu.sex == 1 ? "男":"女",stu.age,stu.score); } void showAllStudentInformation(struct STI *s,int count) { int i; printf("学生信息\n"); printf("%8s %-16s %4s %4s %s\n","学号","姓名","性别","年龄","成绩"); for(i = 0;i < count;i++) { showOneStudentInformation(s[i]); } } int inputStudentInformation(struct STI *st,int maxCount) { int cnt = 0; char id[9]; char name[17]; int sex; int age; float score; printf("请输入学号(学号为空,结束输入):"); gets(id); while(*id != 0) { strcpy(st[cnt].id, id); printf("请输入姓名"); flushall(); gets(name); printf("请输入性别(1表示男,0表示女):"); scanf("%d",&sex); st[cnt].sex = (sex == 1 ? 'm' : 'f'); printf("请输入年龄"); scanf("%d",&age); st[cnt].age = age; printf("请输入成绩"); scanf("%lf",&score); st[cnt].score = score; printf("请输入学号(学号为空,结束输入):"); flushall(); gets(id); cnt++; } return cnt; } void main(void) { struct STI stu1[50] ={0}; int count1 = 0; //先实现信息的录入(填充内容) count1 = inputStudentInformation(stu1, 50); showAllStudentInformation(stu1,count1); }
0 0
- 一个简单的结构体例题
- 结构体例题汇总
- 结构体例题(一)
- 结构体例题(二)
- 结构体例题(三)
- 结构体例题(四)
- 一个简单的树结构
- 分享seo的全方位优化体例
- 系统设计文档结构体例理解与决策
- 一个简单的win32程序的结构
- 一个简单的三层结构的类
- 一个简单PDF文件的结构分析
- 一个简单的HttpListener服务结构
- 一个简单C程序的结构
- 一个简单PDF文件的结构分析
- 一个简单的HttpListener服务结构
- 一个简单PDF文件的结构分析
- 一个简单的链表结构
- 蓝桥杯——趣味整数问题一(2017.1.30)
- 蓝桥杯练习题——入门训练
- make的使用和Makefile的编写
- vmstat:一个标准的报告虚拟内存统计工具
- WebVeiw的使用随笔
- 一个简单的结构体例题
- 【t066】致命的珠宝
- EmitMapper 和TinyMapper 两者简单对比(若转载请注明)
- FPGA 学习之路(九)SPI协议通信
- MyEclipse部署TomCat服务器
- 使用curses函数库管理基于文本的屏幕
- 详情与概要标签
- codevs天梯 装箱问题 水01背包
- 4 - 3 - Gradient Descent in Practice I - Feature Scaling (9 min)