正在加载图片...
结构体范例 #include<stdio.h> ■ void mainO printi"姓名语文英语n") struct student printf( %ost", score. name) printf(%/od" score. chinese char name 10k: printf(%od n",score. english ) Int chinese int english ■}输出结构体元素 score printf("姓名:") scanf( %s", &score. name print("语文成绩: scanf("od",&score. chinese) print("英语成绩:") anf(%od", &score. english); ∥为结构体元素赋值 北大書写12 ◼ #include <stdio.h> ◼ void main() ◼ { ◼ struct student ◼ { ◼ char name[10]; ◼ int chinese; ◼ int english; ◼ }score; ◼ printf("姓名:"); ◼ scanf("%s",&score.name); ◼ printf("语文成绩:"); ◼ scanf("%d",&score.chinese); ◼ printf("英语成绩:"); ◼ scanf("%d",&score.english); ◼ //为结构体元素赋值 ◼ printf("姓名\t语文\t英语\n"); ◼ printf("%s\t",score.name); ◼ printf("%d\t",score.chinese); ◼ printf("%d\n",score.english); ◼ }//输出结构体元素 结构体范例
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有