获取个十百千位

来源:互联网 发布:伊舜数码淘宝店怎么样 编辑:程序博客网 时间:2024/06/05 17:20
#include<stdio.h>
int main(){
    int n = 123456;
    int unitPlace = n / 1 % 10;
    int tenPlace = n / 10 % 10;
    int hundredPlace = n / 100 % 10;
    int thousandPlace = n / 1000 % 10;
    printf("个位:%d\n十位:%d\n百位:%d\n千位:%d\n", unitPlace, tenPlace, hundredPlace, thousandPlace);
 
    getchar();
    return 0;

}

转自:https://zhidao.baidu.com/question/546147756.html

0 0
原创粉丝点击