-
The C language program written according to the requirements of the topic is as follows.
Question 1. #include
int main(){
int i;
long long sum=0;
long long product=1;
for(i=1;i<=20;i++)
product=product*i;
sum=sum+product;
printf("%lld",sum);
return 0;
Question 1. #include
int main(){
float salary,sum=0;
int i,n;
for(i=0;i<3;i++)
n=0;sum=0;
scanf("%f",&salary);
while(salary!=-1){
sum=sum+salary;
n++;scanf("%f",&salary);
if(n>0)
printf("Team number %d, average salary %2f",i+1,sum/n);
return 0;
-
The function of these two programs: to iterate over the string, and if a space is encountered, to assign the string after the space to the original array.
Observe the first program: after encountering a space and assigning the string after the space to the original array, set the count variable i to 0 in order to re-iterate the new string, and the traversal process will start from the beginning. So the first loop gets a new array"are you!, the second loop gets the new array"you!", so the answer is a
Observing the second program, unlike the previous one, the string is not assigned to the original function and the count variable is not set to 0, so a new string is generated for the first time"are you!"After no longer traversing from the beginning, but from i=4, which is important for new strings"are you!", just skipping the white space, so the end result is still "are you!"., so the answer is a
-
if(a[i]==' ')
strcpy(a,&a[i+1]);
i=0;*The first diagram has i=0 After copying the string after the space to the front, start the comparison from the new a[0], and repeat until the string after the last space is copied to the front * if(a[i]==' ')
strcpy(a,&a[i+1]);*After the second diagram copies are you to a, i does not change (i=3), execute for i++i=4, a[i]=y starts from you.
If doesn't hit spaces, so strcpy* is no longer executed
-
b +=a++;Rather cautious about preceding b = b + a; rea = a + 1;
So the pants end up with a = 3, b = 4, c = 2, and Hu Ming returns 9
-
1 All the symbolic constants defined by defined, when used, the C compilation system will only write them as is, and will not distinguish the priority of the operation.
In this case, define f x+y is used so that f represents x+y
In the formula z=f*f; , people mistakenly mistake f for x+y for f x+y, so z=f*f is understood as z=(x+y)*(x+y)16
In fact, f stands for x+y and substituting z=f*f, which should be z= x+y * x+y 1+ 3 * 1 + 3 1+4+3 7
If you change define f x+y to define f (x+y).
then substituting z=f*f, followed by z= (x+y) *x+y) 4*4 16
Be careful.
-
Well, I don't know where you don't understand, just say it little by little.
First of all, replace the f in the program with x+y, without parentheses.
So z x y x + y
x -- is to use x to compare first, and then subtract 1
2 1, so true, x 2-1 1
z=1+3×1+3=7
The previous step z f 2 3 6 was of little use.
But if it's --x, it's different, it's 6.
-
First of all, x=1, I don't understand what --> means, z=f*f is equal to z=x+y*x+y, so it is equal to 7
-
p->membername or &(*p)membername (when the member is not an array), p->membername, or (*p).membername (when the member is an array), so the answer is a.
2、sum=335
The function of the whole program is to calculate the total number of days in a given year from the first month all the way to the first month of the month entered (taking into account the case of leap years), so the answer is sum=335, if for(i=1; i<;i++) to for(i=1; i<=;i++) is sum=366.
It's not very hard that the tail node next points to null. >>>More
1 Bubbles are produced on the surface of the metal The solution changes from colorless to light green. >>>More
The following questions are answered in the context of high school only. >>>More
I seem to know it, it doesn't seem to know me.
Question 1: The answer is (-1,0), i.e. the open range is -1 to 0 >>>More