輸入一百個變數,找最大值程式
#include"stdafx.h"
#include"iostream"
using namespace std;
int main()
{
cout << "Please input value" << endl;
cout << "Please input z to escape" << endl;
int value=0, counter=0, max=0;
while (counter <= 100)
{
cin >> value;
if (value > max)
{
max = value;
}
else if (value == 'z')
{
break;
}
counter = counter + 1;
}
cout << max;
return 0;
}
#include"iostream"
using namespace std;
int main()
{
cout << "Please input value" << endl;
cout << "Please input z to escape" << endl;
int value=0, counter=0, max=0;
while (counter <= 100)
{
cin >> value;
if (value > max)
{
max = value;
}
else if (value == 'z')
{
break;
}
counter = counter + 1;
}
cout << max;
return 0;
}
留言
張貼留言