为了账号安全,请及时绑定邮箱和手机立即绑定

新手求大神帮忙debug:指针变量作为参数简单应用

新手求大神帮忙debug:指针变量作为参数简单应用

C C++
藏宝alo 2016-05-14 19:45:08
//要求录入学号及对应的分数,找到最高分数,输出最高分数及对应的学号#include <stdio.h>#define N 80int main(){ int n; int score[N];//分数  int number[N];//学号  int maxNum,maxScore; printf("Input:how many students in the class:\n"); scanf("%d",&n); printf("Input:the student number and the score"); int i; for(i=0;i<n;i++){ scanf("%d %d",&number[i],&score[i]); }//输入学号及对应的分数  findMax(&maxScore,&maxNum,n,number[],score[]); printf("maxNum=%d,maxScore=%d",*maxNum,*maxNum); return 0;}//定义函数:寻找最大分数 void findMax(int* maxScore,int* maxNum,int n,int number[],int score[]){ *maxScore=score[0]; *maxNum=number[0]; int i; for(i=1;i<n;i=++){ if(score[i]>*maxScore){ *maxScore=score[i]; *maxNum=number[i]; } } }
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1477 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信