C++线上等啊,谁会啊?
#include<iostream>
using namespace std;
void main()
{ int a=0,b,c1,c2,c3,c4,c5;
cout<<"please put in a";
cin>>a;
if(a>=0&&a<10)b=1;
if(a>9&&a<100)b=2;
if(a>99&&a<1000)b=3;
if(a>999&&a<10000)b=4;
if(a>9999&&a<100000)b=5;
switch(b)
{
case 5:c1=a/10000;a-=c1*10000;
case 4:c2=a/1000;a-=c2*1000;
case 3:c3=a/100;a-=c3*100;
case 2:c4=a/10;;a-=c4*10;
case 1:c5=a;
}
cout<<b<<endl;
cout<<c1<<c2<<c3<<c4<<c5<<endl;
cout<<c5<<c4<<c3<<c2<<c1<<endl;
}
哪里错了啊?
参考答案:不知你程序想干什么?你想不用break然后一直through来使a的值改变吗,应该没问题的,最好加注释,你是执行结果不对还是怎么着?
空白:int a = 0;
cout<<(char)a;
令a为0就是空白了,然后强制类型转换成char
空格:int a = 32;
cout<<(char)a;