Home > Back-end >  Ask, where the code is wrong
Ask, where the code is wrong

Time:09-24

Topic: print n digits (starting at 1) here is my test double-digit
# include
# include
# include
# include
using namespace std;
Int x=0;
Void the print (char Numbers [])
{int I=0;
for( i=0; I{if (Numbers [I]!='0') break;
}
For (int j=I; J{cout}
Cout<" \ t ";
}

Void the set (char Numbers [], int n, int I)
{if (I==n) {print (Numbers);
return; }
While (Numbers [I] <='9')
{//coutSet (Numbers, n, I + 1);
+ + Numbers [I];
x++;
}
}
Void printdigits (int n)
{if (n<=0) return;
Char * Numbers=new char [n + 1);
Numbers [n]='\ 0';
Memset (Numbers, '0', n);
Set (Numbers, n, 0);
The delete [] Numbers;
}
Void main ()
{
Printdigits (2);
Cout<" X="& lt; Cin. The get ();
}

X is a global variable, used to detect the while loop

CodePudding user response:

After tracking debugging is the basic skills, learn to find problem quickly,