Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a program, input an integer data, and output each number, separated by commas. For example, if the input integer is 2345, the output should be 2,3,4,5.
Write a program, input an integer data, and output each number, separated by commas. For example, if the input integer is 2345, the output should be 2,3,4,5.
# include & ltstdio.h & gt

# include & ltstring.h & gt

# include & ltiostream.h & gt

void main()

{

int a,I,k,j = 0;

int b[20];

Cout < < "Enter an integer:";

CIN & gt; & gta;

I = a; //backup a.

while(I & gt; 9)

{ k = I % 10; //The remainder is recorded in the array.

b[j]= k;

I = I/ 10; //I rounded the last bit of the record in the array.

j++;

} j-; //j is a little too much.

Cout & lt& lt me; //i is already less than 10, and the last number is i.

for(; j & gt=0; j -)

cout & lt& lt“,”& lt& ltb[j];

cout & lt& ltendl

getchar();

}

I've been making it up. It seems simple or mysterious! !