求电脑编程

来源:百度知道 编辑:UC知道 时间:2024/06/23 07:54:00
在VB里编程

取所输入数的个位数

如:输入127,打印7;输入20,打印0
比如133.6,打印的是3

#include<stdio.h>
int main()
{
double x;
int y;

x=scanf();
if(x>10&&x=10)
y=(int*)x%10;
else
y=(int*)x;
printf("the number is :%d",y);
return 0;
}
原理基本上相同的

do while a>9
a = a mod 10
loop