标题:[求助]请各位看看这条题只用WHILE和 IF行不...
取消只看楼主
Uruz7
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-5
 问题点数:0 回复次数:0 
[求助]请各位看看这条题只用WHILE和 IF行不...

题目大概是这样的:输入一些数字,输入0终止或者到输入一定数目既数字终止...PRINT最大和最小值出来.

#include <stdio.h>
#include <stdlib.h>
#define MAX 5

int maximum = 0,
minimum = 0,
ctr = 0,
number[MAX],
temp = 1;


int main()
{
ctr = 0;
while ( ctr < MAX && temp != 0 )
{
puts("Enter a number: (Quit = 0)");
scanf("%d", &number[ctr]);
maximum = number[0];
minimum = number[0];
temp = number[ctr];
if ( temp > maximum && temp !=0 )
{ maximum = temp; }
if ( temp < minimum && temp !=0 )
{ minimum = temp; }

ctr++;
}
if (number[0] == 0)
puts("No number is entered");
else
{printf("Largest number is %d\n",maximum);
printf("Smallest number is %d\n",minimum);}
system("PAUSE");

return 0;
}

我看了N小时都看不出来.....请各位来帮忙

搜索更多相关主题的帖子: WHILE 
2006-05-05 08:05



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




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

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