(the purpose of this code is behind the input characters into the fourth letters, China - & gt; Glmre, in front of the code is tied for execution, to let you see the results of difference, namely Glmre)
Problem description: When independent output when performing a second code: Glmre When along with the first piece of code execution output: mouth Glmr
#include #include Int main (void) { //the following is tied for the code, not a major problem { Printf (" hw 3.2 \ n "); Float way, temp; Printf (" please enter the amount: \ n "); The scanf (" % f ", & amp; Temp); Printf (" please enter the deposit (1-5) : \ n "); The scanf (" % f ", & amp; Way); If (way==1) { Temp *=(1 + 5 * 0.03); Printf (" result=% f \ n \ n ", temp); } Else if (way==2) { Temp *=(1 + 2 * 0.021); Temp *=(1 + 3 * 0.0275); Printf (" result=% f \ n \ n ", temp); } Else if (way==3) { Temp *=(1 + 3 * 0.0275); Temp *=(1 + 2 * 0.021); Printf (" result=% f \ n \ n ", temp); } Else if (way==4) { Temp *=pow (1.015, 5); Printf (" result=% f \ n \ n ", temp); } The else { (1 + 0.0035/4 temp *=pow, 20); Printf (" result=% f \ n \ n ", temp); } }
//the following is a question of code { Printf (" hw 3.6 \ n "); Printf (" please enter the 5 digit code: \ n "); Char c [5]; int i; for(i=0; i<5; I++)//a for loop enter multiple characters { [I] c=getchar ();//the input character is assigned to the variable } for(i=0; i<5; I++) { C=c [I] [I] + 4;//behind the input characters into a fourth C [5]='\ 0'; Putchar (c [I]); } Putchar (" \ n "); }