C语言中整数123取十位数表达式

1个回答
展开全部
咨询记录 · 回答于2024-01-19
C语言中整数123取十位数表达式
#include 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", unitPlace); printf("十位:%d\n", tenPlace); printf("百位:%d\n", hundredPlace); printf("千位:%d\n", thousandPlace); getchar(); return 0;
下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消