![]() |
#2
pangding2012-09-05 23:32
|
//题意:要求输入10个字符,求其中ASCII码值最大者。
#include<iostream>
using namespace std;
int main()
{
const int NUM=10; //定义常量
int max,c;
max=0;
cout<<"请输入"<<NUM<<"个字符,系统将输出其中ASCII码最大者:"<<endl;
for(int i=1;i<=NUM;i++)
{ int b;
cout<<i<<endl;
cin>>b;
if(b>max)
max=b;
}
cout<<"其中ASCII码值最大者为:"<<max<<endl;
return 0;
}
我输入的是:w
为什么输出结是:
1
w
2
3
4
5
6
7
8
9
10
其中ASCII码值最大者为:0