| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 415 人关注过本帖
标题:[求助]有个问题要问!
只看楼主 加入收藏
woshihuo12
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-10-31
收藏
 问题点数:0 回复次数:4 
[求助]有个问题要问!


#include<stdio.h>
#include<string.h>
#define N 3
struct staff{
char name[20];
long int num;
short age;
int year;
float salary;
};
void average(struct staff men[],int i);
main()
{
int i;
static struct staff men[N];
struct staff *p;
p=men;
printf("Input data:name,number,age,begin year, salary\n");
for(i=0;i<N;i++)
{scanf("%s",p->name);
if(strcmp(p->name,"ok")==0)
{printf ("data end!\n");
break;}
scanf("d%d%d%",&p->num,&p->age,&p->year);
scanf("%f",&p->salary);
p++;
}

average(men,i);
return 0;
}
void average(struct staff men[],int i)
{
int j,sum_a=0,sum_w=0;
int y,ave_age,ave_w;
float ave_slr,sum_s=0;
printf("Input the number of this year.\n");
scanf("%d",&y);
for(j=0;j<=i;j++)
{
sum_a+=men[j].age;
sum_w+=y-men[j].year;
sum_s+=men[j].salary;
}
ave_age=sum_a/i;
ave_w=sum_w/i;
ave_slr=sum_s/i;
printf("The average of age=%d\n",ave_age);
printf("The average of employed time=%d\n",ave_w);
printf("The average of salary=%f\n",ave_slr);
}
怎么运行啊?我怎么运行不出结果呢????

搜索更多相关主题的帖子: include number 
2007-01-01 19:37
卧龙孔明
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:59
帖 子:3872
专家分:684
注 册:2006-10-13
收藏
得分:0 
直接run就可以了,我用Win-tc编译通过,没有错误,也没有警告信息

My Blog: www.aiexp.info
虽然我的路是从这里开始的,但是这里不再是乐土.感谢曾经影响过,引导过,帮助过我的董凯,飞燕,leeco,starwing,Rockcarry,soft_wind等等等等.别了,BCCN.
2007-01-01 20:53
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
估计出在给结构体成员赋值上.

倚天照海花无数,流水高山心自知。
2007-01-01 21:07
ffaannggqq
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2006-12-23
收藏
得分:0 

#include<stdio.h>
#include<string.h>
#define N 3
struct staff{
char name[20];
long int num;
short age;
int year;
float salary;
};
void average(struct staff men[],int i);
main()
{
int i;
static struct staff men[N];
struct staff *p;
p=men;
printf("Input data:name,number,age,begin year, salary\n");
for(i=0;i<N;i++)
{scanf("%s",p->name);
if(strcmp(p->name,"ok")==0)
{printf ("data end!\n");
break;}
scanf("%d%d%d",&p->num,&p->age,&p->year);
scanf("%f",&p->salary);
p++;
}//i再自加1,此时i==N;

average(men,i);
return 0;
}
void average(struct staff men[],int i)
{
int j,sum_a=0,sum_w=0;
int y,ave_age,ave_w;
float ave_slr,sum_s=0;
printf("Input the number of this year.\n");
scanf("%d",&y);
for(j=0;j<i;j++)
{
sum_a+=men[j].age;
sum_w+=y-men[j].year;
sum_s+=men[j].salary;
}
ave_age=sum_a/i;
ave_w=sum_w/i;
ave_slr=sum_s/i;
printf("The average of age=%d\n",ave_age);
printf("The average of employed time=%d\n",ave_w);
printf("The average of salary=%f\n",ave_slr);
}


2007-01-02 14:12
neverTheSame
Rank: 3Rank: 3
来 自:江西农业大学
等 级:新手上路
威 望:9
帖 子:1511
专家分:0
注 册:2006-11-24
收藏
得分:0 

#include<stdio.h>
#include<string.h>
#define N 3
struct staff{
char name[20];
long int num;
short age;
int year;
float salary;
};
void average(struct staff men[],int i);
main()
{
int i;
static struct staff men[N];
struct staff *p;
p=men;
printf("Input data:name,number,age,begin year, salary\n");
for(i=0;i<N;i++)
{scanf("%s",p->name);
if(strcmp(p->name,"ok")==0)
{printf ("data end!\n");
break;}
/*scanf("d%d%d%",&p->num,&p->age,&p->year); */
scanf("%d%d%d",&p->num,&p->age,&p->year);
scanf("%f",&p->salary);
p++;
}

average(men,i);
return 0;
}
void average(struct staff men[],int i)
{
int j,sum_a=0,sum_w=0;
int y,ave_age,ave_w;
float ave_slr,sum_s=0;
printf("Input the number of this year.\n");
scanf("%d",&y);
for(j=0;j<=i;j++)
{
sum_a+=men[j].age;
sum_w+=y-men[j].year;
sum_s+=men[j].salary;
}
ave_age=sum_a/i;
ave_w=sum_w/i;
ave_slr=sum_s/i;
printf("The average of age=%d\n",ave_age);
printf("The average of employed time=%d\n",ave_w);
printf("The average of salary=%f\n",ave_slr);
}


wap酷禾网(http://wap.),提供免费的、优质的、快捷的wap资源下载服务。
2007-01-02 14:58
快速回复:[求助]有个问题要问!
数据加载中...
 
   



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

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