Where is the decimal to octal transformation problems? Why get run results have nothing (& gt; The man & lt;) Thank you very much
Code:
#include
#include Int main () { Int a=0, t=0, I=0, len. Char c [50]; The scanf (" % d ", & amp; A); If (a!=0) { C=a % 8 + [I] '0'; A=a/8; i++; } Len=strlen (c); for(i=0; i<=len/2; I++) { T=c [I]; [I] c=c [len - I - 1); C [len - I - 1]=t; } Printf (" % s \ n ", c); return 0; } CodePudding user response:
Didn't finish see at least the if (a!=0) should be the while (a!=0) CodePudding user response:
reference 1st floor bo_self_effacing response: didn't finish see if at least (a!=0) should be the while (a!=0). Oh oh oh, yes, it is a while, thank you Then run is still the same result after changed CodePudding user response:
refer to the second floor just learning programming rookie reply: Quote: refer to 1st floor bo_self_effacing response: didn't finish see at least the if (a!=0) should be the while (a!=0). Oh oh oh, yes, it is a while, thank you And then changed after still run results C [len]='\ 0';//add try here Printf (" % s \ n ", c); CodePudding user response:
Thank you, I tried, still is empty (& gt; The man & lt;) CodePudding user response:
Vc + + 6.0 my favourite, no one # include # include & lt; String. H> Int main (int arg c, char * argv []) { Int a=0, t=0, I=0, len. Char c [50]={0};//-- -- -- -- -- -- -- -- -- must be initialized, otherwise the strlen is not want to get the length of the -- -- -- -- -- -- -- -- The scanf (" % d ", & amp; A); While (a!=0)//-- -- -- -- -- -- -- -- -- -- if while instead -- -- -- -- -- -- -- -- -- -- -- -- { C=a % 8 + [I] '0'; A=a/8; i++; } Len=strlen (c); for(i=0; i { T=c [I]; [I] c=c [len - I - 1); C [len - I - 1]=t; } Printf (" % s \ n ", c); return 0; } Vc + + 6.0 debugging CodePudding user response:
# include #include Int main () { Int a=0, t=0, I=0, len. Char c [50] {0}; The scanf (" % d ", & amp; A); While (a!=0) { C=a % 8 + [I] '0'; A=a/8; i++; } Len=strlen (c); For (I=0; i <=len/2; I++) { T=c [I]; [I] c=c [len - I - 1); C [len - I - 1]=t; } Printf (" % s \ n ", c); return 0; } The same is what I have other output; CodePudding user response:
reference bo_self_effacing reply: 3/f Quote: refer to the second floor just learning programming rookie reply: Quote: refer to 1st floor bo_self_effacing response: didn't finish see at least the if (a!=0) should be the while (a!=0). Oh oh oh, yes, it is a while, thank you And then changed after still run results C [len]='\ 0';//add try here Printf (" % s \ n ", c); Well, the other is wrong, because no first initialize array c, len=strlen (c) the len is not reliable, CodePudding user response:
refer to 6th floor bo_self_effacing response: # include #include Int main () { Int a=0, t=0, I=0, len. Char c [50] {0}; The scanf (" % d ", & amp; A); While (a!=0) { C=a % 8 + [I] '0'; A=a/8; i++; } Len=strlen (c); For (I=0; i <=len/2; I++) { T=c [I]; [I] c=c [len - I - 1); C [len - I - 1]=t; } Printf (" % s \ n ", c); return 0; } The same is what I have other output; Maybe because I c [50] no initialization, thank you CodePudding user response:
Understand, thank you CodePudding user response:
reference 5 floor MianHou reply: vc + + 6.0 my favourite, no one # include # include & lt; String. H> Int main (int arg c, char * argv []) { Int a=0, t=0, I=0, len. Char c [50]={0};//-- -- -- -- -- -- -- -- -- must be initialized, otherwise the strlen is not want to get the length of the -- -- -- -- -- -- -- -- The scanf (" % d ", & amp; A); While (a!=0)//-- -- -- -- -- -- -- -- -- -- if while instead -- -- -- -- -- -- -- -- -- -- -- -- { C=a % 8 + [I] '0'; A=a/8; i++; } Len=strlen (c); for(i=0; i { T=c [I]; [I] c=c [len - I - 1); C [len - I - 1]=t; } Printf (" % s \ n ", c); return 0; } Vc + + 6.0 debugging Understand, thank you CodePudding user response:
references to the tenth floor just learning programming rookie reply: Quote: refer to the fifth floor MianHou reply: vc + + 6.0 my favourite, no one # include # include & lt; String. H> Int main (int arg c, char * argv []) { Int a=0, t=0, I=0, len. Char c [50]={0};//-- -- -- -- -- -- -- -- -- must be initialized, otherwise the strlen is not want to get the length of the -- -- -- -- -- -- -- -- The scanf (" % d ", & amp; A); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull