#include<iostream>
using namespace std;
int string2int(string xc) {
int hy = 0;
for (int i = 0; i < xc.length(); i++) {
if (xc[i] >= '0' && xc[i] <= '9')
hy = hy * 10 + (int)(xc[i] - '0');
else{
xc = "请正确输入一个数!!!\n";
throw xc;//报错
}
}
return hy;
}
int main() {
string xc;
int hy;
while (1)
{
try {
cout << "\n输入一个数(退出--break):";
cin >> xc;
if (xc == "break")
break;
hy = string2int(xc);
cout << hy;
}
catch (string wr) {
cout << wr;
}
}
}