current position:Home>How can the following code input three numbers without spaces for the third time, such as 234

How can the following code input three numbers without spaces for the third time, such as 234

2022-01-27 01:09:26 CSDN Q & A

    for(i=0;i<13;i++)    {        scanf("%d",&a[i]);    }    scanf("%d %d",&n,&m);    for(i=0;i<n;i++)    {    scanf("%d",&b[i]);}



Refer to the answer 1:
    for (i = 0; i < 13; i++)    {        if (i==2)        {            scanf("%d", &a[i]);            a[i + 1] = a[i] / 10 % 10;            a[i + 2] = a[i] % 100 % 10;            a[i] = a[i] / 100;            i += 2;        }        scanf("%d", &a[i]);    }



Refer to the answer 2:



Refer to the answer 3:

1 The answer given by Lou is : You enter a three digit number , Then use division and remainder to find the hundreds 、 ten 、 bits
In fact, it can also be used %c%c%c Read by 3 Characters , Read and subtract '0' convert to int




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270109244954.html

Random recommended