练习39

二级C语言必过教程

共 1215字,需浏览 3分钟

 ·

2021-07-29 22:39

点击蓝字

关注我们

DRAGON BOAT FESTIVAL




练习39



01 要求:

建立同学通讯录

例如:

输入姓名:张三,电话:100等

输出通讯录信息



02 程序示例如下:

// 建立同学通讯录

#include"stdio.h"#define NUM 3struct mem{ char name[20]; char phone[10];};int main(){ struct mem man[NUM]; int i; for (i = 0; i<NUM; i++) { printf("input name:\n"); gets(man[i].name); printf("input phone:\n"); gets(man[i].phone); } printf("name\t\t\tphone\n\n"); for (i = 0; i<NUM; i++) printf("%s\t\t\t%s\n", man[i].name, man[i].phone); return 0;}



03:输出:

input name:

张三

input phone:

100

input name:

李四

input phone:

101

input name:

赵五

input phone:

102

name                    phone


张三                    100

李四                    101

赵五                    102




球分享

球点赞

球在看


浏览 7
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报