Write a program to input 3 integer digits (from 100 - 999), then in the numbers letters in hundreds, tens, and units ?

16 次查看(过去 30 天)
I need help
  2 个评论
Minh
Minh 2022-9-21
编辑:Minh 2022-9-21
Can you convert this c++ code to matlab for me?
void main ()
{
int x;
do
{
printf ( "\ nx =" );
scanf ( "% d" , & x);
}
while (x <100 || x> 999);
printf ( "\ n hundreds :% d" , x, x / 100);
printf ( "\ n tens :% d" , x, (x% 100) / 10);
printf ( "\ n units :% d" , x, (x% 100)% 10);
getch ();

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2022-9-21
  1 个评论
Minh
Minh 2022-9-21
I can't convert when reading this document, can you give more instructions ?
void main()
{
int x;
do
{
printf("\n x = ");
scanf("%d", &x);
}
while(x < 100 || x > 999 );
printf("\n hundreds : %d", x, x/100);
printf("\n tens: %d", x, (x%100)/10);
printf("\n units: %d", x, (x%100)%10);
getch();
}

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by