标题:应用指针函数求最大分和最小分的学生学号。弃用数组,善于创新。。喜欢的话 ...
取消只看楼主
岳三路
Rank: 2
等 级:论坛游民
帖 子:23
专家分:19
注 册:2011-3-30
结帖率:60%
已结贴  问题点数:20 回复次数:3 
应用指针函数求最大分和最小分的学生学号。弃用数组,善于创新。。喜欢的话大家给点意见。。
#include <stdio.h>
#define ARR_SIZE 40
void FindMax(float score[],long num[],int n,float *pMaxScore,long *pMaxNum);
main()
{
    float score[ARR_SIZE],maxScore;
    long num[ARR_SIZE],maxNum;
    int n,i;
    printf("Please enter total number:");
    scanf("%d",&n);
    printf("Please enter the number and score:\n");
    for (i=0;i<n;i++)
    {
        scanf("%ld%f",&num[i],&score[i]);
    }
    FindMax(score,num,n,&maxScore,&maxNum);
    printf("maxScore=%.0f,maxNum=%ld\n",maxScore,maxNum);
}
void FindMax(float score[],long num[],int n,float *pMaxScore,long *pMaxNum)
{
    int i;
    *pMaxScore=score[0];
    *pMaxNum=num[0];
    for (i=1;i<n;i++)
    {
        if (score[i]>*pMaxScore)
        {
            *pMaxScore=score[i];
            *pMaxNum=num[i];
        }
    }
}
搜索更多相关主题的帖子: include number 创新 
2011-04-19 00:08
岳三路
Rank: 2
等 级:论坛游民
帖 子:23
专家分:19
注 册:2011-3-30
得分:0 
回复 3楼 帅的让人抽
受教了。。谢谢。。
2011-04-19 20:48
岳三路
Rank: 2
等 级:论坛游民
帖 子:23
专家分:19
注 册:2011-3-30
得分:0 
回复 2楼 voidx
嗯,我只是偶然想用指针函数来试试。。嘻嘻
2011-04-19 20:49
岳三路
Rank: 2
等 级:论坛游民
帖 子:23
专家分:19
注 册:2011-3-30
得分:0 
回复 6楼 laoyang103
嗯,我也不太懂什么是指针函数。。这东西太绕人了(上课走神了)。。。。
2011-04-19 21:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-337171-1-1.html




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

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