-
main() [main function main program].
int i,j,k;【Define integer data i,j,k】for(i=1; i<=6;i++) main loop, i from 1 to 6, increasing to 1] for(j=1; j<=20-2*i;j++) subcycle, j from 1 to 20-2*i
Increment to 1]printf(" ");[Output.]""】for(k=1;k<=i;k++) subcycle, K from 1 to i, incrementing to 1] printf("%4d", i );Output the value of i with the rule of %4d (four characters with the original data retained if exceeded).
printf(" ");
-
main()
int i,j,k;
for(i=1;i<=6;i++) has a total of three layers of circulation, which is the outermost layer.
for(j=1;j<=20-2*i;j++) This is the second layer of the loop, when i; =1, j< 18, i=2; j<=16;i=3;j<=14...
printf(" ");i=1; Print 18 spaces, i=2 print 16 spaces.
for(k=1;k<=i;k++) third-layer loop.
printf("%4d", i );Print the value of i.
printf(" ");Line breaks.
-
The steps are given by everyone.
-
This problem is of difficulty to C language entry level, and the solution is very simple, only need to pass a simple if....else statement. The details are as follows:
#include
using namespace std;
int main()
int a;
cout<<"Enter the grade:";
cin>>a;
if(a>limb rotten 0 | a <=100)elseelsereturn 0;
-
p++ is p=p+1, which is a formula, because p already points to the first element of the array, and the address pointer of p (which stores the address) is moved back once, so that p points to the address of the next array element, and an integer can be read into the next array element when the next loop is executed.
-
Pointers, more abstract. ......For example, if a book is an array a, the first page is a[0], the second page is a[1], and so on. Then p is the bookmark of the book, at the beginning of the bookmark on the first page, that is, p points to a[0], at this time, the input assignment is "turn to the page of the bookmark, write a value".
-
&a[0] is equivalent to a+0, which is equivalent to a, and because the assignment statement p=a, it is equivalent to p
&a[0] is equivalent to a+1, i.e., p+1
The same goes for the follow-up
-
It should be: 353
bSince there are no curly braces after if, this one only has t=a; This statement is t=a under this judgment;
The value of t after this sentence is executed is 3
a=c;The value of a after this sentence is executed is 5
c=t;The value of c after this sentence is executed is 3
aSince there are no curly braces after if, t=b; In this judgment, but a=5, b=4, c=3, because the condition is not satisfied, so t=b; Not executed.
b=a;The value of b after this sentence is executed is 5
a=t;The value of a after this sentence is executed is 3
Therefore, the final output is 353
-
Landlord, do you change to: define(x,y) (x>y?x:y) Give it a try.
Change this place a bit, and the output is correct. Here's why.
Why, the specific reasons have not been analyzed.
-
The program itself is buggy. After the correction, the result of the operation is:
Error 1: In the first for loop, k-0 is changed to k=0;
This problem requires understanding that the system allocates memory to static variables when compiling, and the memory units occupied by them are not released after the function call ends, that is, the value of the variable is the value of the previous function call at the next function call. >>>More
Scope. You static char *chh;
static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More
2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More
C++ is an object-oriented language, not very easy to learn, because it is more flexible, so there are a lot of problems to consider when doing programs! Because of the direct operation of the hardware, it inherits the advantages of the C language, so it is very efficient, and is generally used for the underlying and embedded systems.
It's a shame to ask your question, one is the development environment, the other is the language, what's the difference, you're laughing to death.