65,176
社区成员




#include<iostream>
using namespace std;
void main()
{
bool k=true;
int ch=0;
while(k)
{
cout<<"------------------------------------------------------------------|"<<endl;
cout<<"| 1、输入文件路径 2、计算灰度 |"<<endl;
cout<<"| 3、显示灰度 4、保存灰度 |"<<endl;
cout<<"| 5、退出 |"<<endl;
cout<<"-------------------------------------------------------------------"<<endl;
cin>>ch;
cout<<"ch="<<ch<<endl;
switch(ch)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
k=false;
break;
default:
break;
}
cin.clear(); //加上这两行会忽略非数字的输入,就不会死循环了。
cin.ignore();
}
}
void GetMonth() //从键盘输入获得月份
{
string s_month;
do
{
cout<<"Input the month:"<<endl;
cin>>s_month;
month = StrToNum(s_month);
}while (month < january || month > December);
}
int StrToNum(string &s) //字符串转数字
{
int Num;
stringstream ss(s);
ss>>Num;
return Num;
}
string NumTostr(int &i) //数字转字符串
{
stringstream ss;
ss<<i;
return ss.str();
}