void print c语言,数据结构(c语言版)习题集第一章绪论1.16voidprint_descending(intx.doc

数据结构(c语言版)习题集第一章绪论1.16voidprint_descending(intx.doc

第一章 绪论

1.16

void print_descending(int x,int y,int z)//按从大到小顺序输出三个数{ scanf("%d,%d,%d",&x,&y,&z); if(xy; //为表示交换的双目运算符,以下同 if(yz; if(xy; //冒泡排序 printf("%d %d %d",x,y,z);}//print_descending

1.17

Status fib(int k,int m,int &f)//求k阶斐波那契序列的第m项的值f{???int tempd;??if(k<2||m<0) return ERROR; ??if(m

1.18

typedef struct{????????????? ???char *sport;??????????????? ?enum{male,female} gender; ????????????????char schoolname; //校名为'A','B','C','D'或'E'??????? ?????????char *result;?????????????? ??int score;????????????? ?} resulttype;

typedef struct{????????????? ???int malescore;????????????? ???int femalescore;????????????? ???int totalscore;????????????? ?} scoretype;

void summary(resulttype result[ ])//求各校的男女总分和团体总分,假设结果已经储存在result[ ]数组中{??scoretype score[MAXSIZE];??i=0;??while(result[i].sport!=NULL)??{????switch(result[i].schoolname)????{??????case 'A':????????score[ 0 ].totalscore+=result[i].score;????????if(result[i].gender==0) score[ 0 ].malescore+=result[i].score;????????else score[ 0 ].femalescore+=result[i].score;????????break;??????case 'B':????????score[ 0 ].totalscore+=result[i].score;????????if(result[i].gender==0) score[ 0 ].malescore+=result[i].score;????????else score[ 0 ].femalescore+=result[i].score;????????break;??????……????……????……????}????i++;??}??for(i=0;i<5;i++)??{????printf("School %d:\n",i);????printf("Total score of male:%d\n",score[i].malescore);????printf("Total score of female:%d\n",score[

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值