C++ 实现一段代码,循环接收用户输入,当用户输入0的时候退出。输入1到9的数字时候,打印出该数字的10倍。输入的不是0-9数字的时候,提示 不是数字。
#include <iostream>
using namespace std;
int main()
{
char n;
cin>>n;
while(n != '0')
{
if(n>='1' && n<='9')
cout<<(n-'0')*10<<endl;
else
cout<<"不是数字"<<endl;
cin >> n;
}
return 0;
}