题目大概是这样的:输入一些数字,输入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小时都看不出来.....请各位来帮忙