C++程序:
#include
using namespace std;
int main()
{
int num;
int a, b, c;
printf("请输入一个三位数:");
cin>>num;
a = num / 100;
b = num / 10 % 10;
c = num % 10;
cout<<"三位数字分别是:"<
return 0;
}
运行测试:
请输入一个三位数:123
三位数字分别是:1 2 3
void main(){
int num,a,b,c;
printf("请输入已个三位正整数:\n");
scanf("%d",&num);
a=num/100;
b=(num%100)/10;
c=num%10;
printf("百位:%d,十位:%d,个位:%d",a,b,c);
}