C++程序设计第4章结构体、枚举类型.ppt
- blingjingya个人认证 |
- 2021-04-16 发布|
- 107 KB|
- 30页
C++;主要内容;结构体类型的定义;结构体类型的定义;结构体变量的定义;结构体变量的定义;结构体变量的使用;【例】
#include<iostream.h>
#include<string.h>
struct student { int id ; char name[ 10 ] ; char sex ; float score ; } ;
void main ( )
{ student s1 = { 408001 , “张小笑” , ‘m’ , 98 } ; cout <<“s1=”<< s1.id <<‘\t’<< s1.name <<‘\t’<< s1.sex <<‘\t’<< s1.score << endl; student s2 , s3 ; cout << “请输入学号 、姓名 、性别( m / f ) 、成绩 :\n” ; cin >> s2.id >> s2.name >> s2.sex >> s2.score ; cout <<“s2=”<< s2.id <<‘\t’<< s2.name <<‘\t’<< s2.sex <<‘\t’<< s2.score << endl; s3 = s2 ; cout <<“s3=”<< s3.id <<‘\t’<< s3.name <<‘\t’<< s3.sex <<‘\t’<< s3.score << endl; s3