摘要: 在一个结构体数组中存入十个人的姓名及年龄,按照年纪升序排列并输出每个人的名字与年龄。 #include <stdio.h> #include <stdlib.h> #include <string.h> int at; char mt[20]; struct student{ char name[2 阅读全文
posted @ 2017-11-05 22:48 梦醒青春时 阅读(420) 评论(0) 推荐(0) 编辑
摘要: 定义一个结构体变量(包括年、月、日)。编写一个函数DAYS,计算该日期在本年中是第几天(注意闰年问题)。 由主函数将年月日传递给DAYS函数,计算之后,将结果传回到主函数输出。 #include <stdio.h> #include <stdlib.h> int days; struct ymd{ 阅读全文
posted @ 2017-11-05 22:45 梦醒青春时 阅读(457) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> struct Salary{ char name[20]; int years; int salary; }stu[5]; int main() { // struct Salary stu[5]; int i; prin 阅读全文
posted @ 2017-11-05 22:09 梦醒青春时 阅读(2405) 评论(0) 推荐(0) 编辑
摘要: c语言如果需要不同类型的一个集合时,数组就不能用,这时候我们就会用结构体struct; 1.结构体的定义: struct 结构体名 {成员列表}; 结构体名,用作结构体类型的标志,它又称 结构体标记,大括号内是该结构体中的各个成员,由它们组成一个结构体,对各成员都应进行类型声明如: 类型名 成员名; 阅读全文
posted @ 2017-11-05 22:04 梦醒青春时 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 1.假设每班人数最多不超过30人,具体人数由键盘输入,试编程打印最高分及其学号。 要求:用一维数组和指针变量作函数参数,编程打印某班一门课成绩的最高分和学号 #include <stdio.h> #include <stdlib.h> int x,temp=0; int GradIsExist(in 阅读全文
posted @ 2017-10-29 14:20 梦醒青春时 阅读(503) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int change(char *p,int n,char *q){/*传入参数(传入指针,开始位置,结束位置!),并且输出写入数组,输出截断后的字符*/ char b[100]; int i=0; p=p+n-1; for(p;p<q;p++){ i++; b[ 阅读全文
posted @ 2017-10-29 14:15 梦醒青春时 阅读(2117) 评论(0) 推荐(0) 编辑
摘要: 一般来说我们需要知道字符或者数组的长度的时候我们会用到strlen()和sizeof(). 1.strlen是函数,sizeof是操作符。 1)sizeof, 在头文件中typedef为unsigned int,其值在编译时即计算好了,参数可以是数组、指针、类型、对象、函数等。 它的功能是:获得保证 阅读全文
posted @ 2017-10-29 14:09 梦醒青春时 阅读(419) 评论(0) 推荐(0) 编辑
摘要: c语言中定义一个数组,如何获取数组的长度有时是我们必须所用到的。引出sizeof和strlen! 1.sizeof与strlen()比较strlen计算字符数组的字符数,以"\0"为结束判断,不计算为'\0'的数组元素。sizeof计算数据(包括数组、变量、类型、结构体等)所占内存空间,用字节数表示 阅读全文
posted @ 2017-10-25 22:26 梦醒青春时 阅读(15196) 评论(0) 推荐(0) 编辑