Home > Back-end >  On C language PTA subject fall into the trap of number one
On C language PTA subject fall into the trap of number one

Time:10-04

Has always been a part of the right, I want to ask where is this code needs to be improved, thank you very much!
 # include & lt; stdio.h> 
Void sum (int n)
{
Int sumn, t, I=0, num=1;
While (sumn! Num)={
Num=sumn;
Sumn=0;
While (n!=0) {
T=n;
T=t % 10;
N=n/10;
Sumn +=t;
}
Sumn=sumn * 3 + 1;
N=sumn;
I=I + 1;
Printf (" % d: % d \ n ", I, sumn);
}
}
Int main ()
{
int n;
The scanf (" % d ", & amp; N);
Getchar ();
The sum (n);
return 0;
}

CodePudding user response:

Where does the pta

I also do a do

Try to use your code

CodePudding user response:

Sorry, forgot to send the topic request,

CodePudding user response:

CodePudding user response:

The first
Your sumn uninitialized, while the first execution (sumn!=sun) can be any value

The second
If the incoming n is 0, how will

CodePudding user response:

Oww, n=0, you already considered
See sumn initial value

CodePudding user response:

Buy the original poster is

I took half a day did not find

Should be sumn initialization, such as the pta is very high for this request

CodePudding user response:

The
refer to 6th floor? Victor.?? Response:
the building Lord: is it a problem to buy

I took half a day did not find

Should be sumn initialization, pta, such as high about this
is not a problem, I bought is a problem in the teacher the assignment,

CodePudding user response:

The
refer to 6th floor? Victor.?? Response:
the building Lord: is it a problem to buy

I took half a day did not find

Should be sumn initialization, pta, such as high about this
thank you, I try,

CodePudding user response:

Fun
reference 4 floor response:

1Your sumn uninitialized, while the first execution (sumn!=sun) can be any value

The second
If the incoming n is 0, how will
thank you, thank you
  • Related