Small white a computer, what all can't, you will make a great god can help me solve this problem? Or what is the recommended way to learn C language?
CodePudding user response:
The first topic is divided into molecular denominator to see on the second question is a person to make a digital algorithm suggested that look at my blog
CodePudding user response:
Question 1: int n; The scanf (" % d ", & amp; N); Float factor=1.0; Float data=https://bbs.csdn.net/topics/0.0; For (count=1; The count & lt;=n; Count + +) { Factor data +=1 * * 1.0/count; } Printf (" data: % f \ n ", data);
Question 2: make the 5 digit character array processing, each character is one of the character array, will this character array can be inverted,
CodePudding user response:
# include & lt; stdio.h> # include & lt; Stdlib. H>
Int main () { int n; int i; Double data=https://bbs.csdn.net/topics/0; Printf (" \ n * * * * * * * * * * * * * * * * * * * * * * * * * \ n "); Printf (" please enter an odd number: "); The scanf (" % d ", & amp; N); If (n % 2!=0) { for(i=1; i <=n; I + +) { The data +=pow (1, I + 1) * 1/I; } Printf (" data: % f \ n ", data); } The else { Printf (" please enter an odd number "); } Printf (" \ n * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Int a, [5]. for(i=0; i <5; I++) { Printf (" please input the first number: % d ", I + 1); The scanf (" % d ", & amp; A [I]); } Printf (" you input array is: "); For (I=4; i>=0; I -) Printf (" % \ t - 6 d, "a [I]); Printf (" \ n * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");