M
mmay172
Guest
I wrote
using System;
class MainClass
{
public static void Main (string[] args)
{
int max=0,min=0,minp=0,maxp=0,num;
Console.Write("give me a positive number: ");
num=int.Parse(Console.ReadLine());
while(num!=0)
{
if(num!=0)
{
if(max<num)
{
max=num;
maxp++;
}
if(min>num)
{
min=num;
minp++;
}
Console.Write("give me a positive number: ");
num=int.Parse(Console.ReadLine());
}
}
Console.WriteLine("the Max is: {0} and his position is:{1}",max,maxp);
Console.WriteLine("the Min is: {0} and his position is: {1}",min,minp);
}
}
and the result was when I entered:
2,4,6,9,0
The Max is : 9 and his position is : 4
The Min is : 0 and his position is : 0
how to make it right?..
Continue reading...
using System;
class MainClass
{
public static void Main (string[] args)
{
int max=0,min=0,minp=0,maxp=0,num;
Console.Write("give me a positive number: ");
num=int.Parse(Console.ReadLine());
while(num!=0)
{
if(num!=0)
{
if(max<num)
{
max=num;
maxp++;
}
if(min>num)
{
min=num;
minp++;
}
Console.Write("give me a positive number: ");
num=int.Parse(Console.ReadLine());
}
}
Console.WriteLine("the Max is: {0} and his position is:{1}",max,maxp);
Console.WriteLine("the Min is: {0} and his position is: {1}",min,minp);
}
}
and the result was when I entered:
2,4,6,9,0
The Max is : 9 and his position is : 4
The Min is : 0 and his position is : 0
how to make it right?..
Continue reading...