Welcome Guest.

1Answers

What does this C++ code mean?

Asked by: Hill 189 views IT November 13, 2018

#include <bits/stdc++.h>

using namespace std;

 

int main()

{

int x, n=0;

int i=0;

int data[5];

 

cin>>x;

while(x)

{

n++;

data[ i++] = x % 10;

x /= 10;

}

cout<<n<<endl;

 

for( i=0; i<n; i++)

{

cout<data[ni-1]<<<<;endl;

}

return 0;

}

(Enter an integer no more than four digits, output it Number of digits and numbers on each digit.)

1 Answers

  1. +6Votes  

    This program does input a number less than 4 digits, and outputs its number and number.

    This is someone else’s program. If you are a beginner, it doesn’t make sense to see such a program

    Because you are not familiar with the grammar, it is impossible to understand other people’s algorithm ideas.

    The personal suggestion is to write the program according to your own ideas (the same requirements, more methods), so that There is improvement

    Otherwise you will understand the other people’s programs even if you know them, you will not write if you encounter new problems

    Thomas- November 14, 2018 |