正在加载图片...
例71(1) 厂【例71】利用结构体对三名学生的学号、姓名、性别、成绩进行输入与输出。 程序名为171cpp #include stdio. h" struct stu i long int num; char name 程 [20]; char sex 序 float score |} student l, student2=(96002 Zhang hong,Ww.8; student3/*对 student2初始化* main( student l, num=960001 /*对 student1各成员赋值*/ scanf("%s",student 1 name) student l sex=M 白 student 1 score=65 student=student1 *对 student3直接赋值 环 境 返回7.1.2目录例7.1(1) 《 C 语 言 程 序 设 计 》(Visual C++ .6 0 环 境 ) 返回7.1.2目录 【例7.1】利用结构体对三名学生的学号、姓名、性别、成绩进行输入与输出。 程序名为l7_1.cpp。 #include "stdio.h" struct stu { long int num; char name[20]; char sex; float score; }student1,student2={960002,"Zhang hong li",'W',98},student3;/*对student2初始化*/ main() { student1.num=960001; /*对student1各成员赋值*/ scanf("%s",student1.name); student1.sex='M'; student1.score=65; student3=student1; /*对student3直接赋值*/
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有