| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 613 人关注过本帖
标题:有点迷茫,做不出来。请大家帮忙!
只看楼主 加入收藏
kappa
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-1-10
收藏
 问题点数:0 回复次数:3 
有点迷茫,做不出来。请大家帮忙!
题目:编写一个C程序,从用户那里获得工资和年龄,然后将这些信息输入到屏幕上。


请大家做出来给我参考下,谢谢!
2005-01-13 21:14
amzyb
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2005-1-10
收藏
得分:0 

#include <stdio.h> struct yonghu{ int num; char name[20]; char sex; int age; long salary; }yh[3]={{001,"liyong",'M',21,2000},{002,"xiaoli",'F',23,1700},{003,"xiaoma",'M',24,5000}}; //struct yonghu yh[3]; void again1(struct yonghu yh[3]){ int i; int n; printf("Select one yonghu by inputing his num:\n"); scanf("%d",&n); for(i=0;i<3;i++){ if(n==yh[i].num){ printf("The age of this yonghu is %d; and his salary is %d\n",yh[i].age,yh[i].salary); break; } if(i==2) printf("The yonghu you want to find is out of research!!\n"); } } int main(){ int s=0;

/* for(i=0;i<3;i++){ printf("Input the messages of the yonghu for use:\n"); printf("num:\n"); scanf("%d",&yh[i].num); printf("name:\n"); scanf("%s",&yh[i].name); //printf("\n"); printf("sex:\n"); scanf("%s",&yh[i].sex); printf("age:\n"); scanf("%d",&yh[i].age); printf("salary:\n"); scanf("%d",&yh[i].salary); printf("\n"); }*/ again1(yh); next1: printf("Select 1 to get more service or 2 to quit:"); scanf("%d",&s); if(s==1){ again1(yh); goto next1; } else if(s==2) return s; else if(s!=1&&s!=2){ printf("Your input is wrong, please chose again!\n"); goto next1; } } 没时间了,就不再注释了,你自己看看吧! 给注释掉的部分是初始化的部分,不太重要,你要是想灵活些可以启用之自己进行初始化。 有一个bug,就是我没有设置初始化用户个数的人为控制,不过很简单了!呵呵!

2005-01-13 23:25
amzyb
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2005-1-10
收藏
得分:0 
^_^
本想黑你一些悬赏积分呢,不过写好了一得意就忘了!
便宜你了哦!:)
2005-01-13 23:27
kappa
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-1-10
收藏
得分:0 
谢谢楼上的这位朋友,辛苦你了!
2005-01-14 00:03
快速回复:有点迷茫,做不出来。请大家帮忙!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014331 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved