课本例题
#include<stdio.h> int main() { /*x,bw,sw,gw分别用来存放三位正整数及其百位,十位和个位数*/ int x, bw, sw, gw; printf("请输入一个三位正整数: "); scanf_s("%d", &x); bw = x / 100; sw = (x % 100) / 10; gw = x % 10; printf("个位数为%d 十位数为%d 百位数为%d", gw, sw, bw); return 0; }
课本例题
#include<stdio.h> int main() { /*x,bw,sw,gw分别用来存放三位正整数及其百位,十位和个位数*/ int x, bw, sw, gw; printf("请输入一个三位正整数: "); scanf_s("%d", &x); bw = x / 100; sw = (x % 100) / 10; gw = x % 10; printf("个位数为%d 十位数为%d 百位数为%d", gw, sw, bw); return 0; }