《C语言及程序设计》实践参考——多数中的最大

来源:互联网 发布:js url encode gbk 编辑:程序博客网 时间:2024/05/15 17:32

返回:贺老师课程教学链接  项目要求


【项目4:多数中的最大】
编程序,输入10个整数,找出最大数。
请在下面代码的基础上完成程序:
#include <stdio.h>int main( ){    int  k,x,max;    scanf("%d", &x);    max=______;                 // (1)    for(k=2;  k<=___ ; k++)     //  (2)    {        scanf("%d", &x);        if (_______)            //  (3)            max=x;      }    printf("Max=%d\n", max);    return 0;}

[参考解答]
#include <stdio.h>int main( ){    int  k,x,max;    scanf("%d", &x);    max=x;                 // (1)    for(k=2;  k<=10; k++)     //  (2)    {        scanf("%d", &x);        if (max<x)            //  (3)            max=x;    }    printf("Max=%d\n", max);    return 0;}



0 0