Single choice questions (20 branch )
1. In a length of n Single linked list of leading nodes h upper , Tail pointer r, Then execute () The operation is related to the length of the linked list .
A Insert a new element after the last element of the single linked list
B Insert a new element before the first element of the single linked list
C Delete the last element in the single linked list
D Delete the first element in the single linked list
Reference answer :C
2. Cow story : There is a big cow , It gives birth to a heifer every year , Each heifer starts in its fourth year , A heifer is also born at the beginning of each year . ask : stay n In , How many heifers are there ?()
#include<stdio.h> int main() { long f[10]; int i,n; scanf("%d",&n);
f[1]=1;f[2]=2;f[3]=3;// boundary for(i=4;i<=n;i++) { f[i]=______;// Recurrence formula printf("%d
%ld\n",i,f[i]); } return 0; }
A f[i-3]+f[i-1]
B f[i]+f[i-1]
C f[i-3]+f[i-2]
D f[i-2]+f[i-1]
Reference answer :A
3.5 Sitting together , Ask the first 5 How old is the individual ? He said Biddy 4 Personal big 2 year . Ask the first 4 Individual age , He said Biddy 3 Personal big 2 year . Ask the first 3 personal , Again, Biddy 2 People are two years old . Ask the first 2 personal , Say bidi 1 I'm two years older . Finally, ask No 1 personal , He said yes 10 year . How old is the fifth person ? ( )
#include<stdio.h> int age(int n) { if(n==1)return (10); else return _____; }
int main() { int n=5; printf("The fifth age is %d.\n",age(n)); return 0; }
A age(n-2)+2
B age(n)+2
C age(n-1)+2
D age(n-1)
Reference answer :C
4. It is known that a pair of rabbits can give birth to a pair of rabbits every month , A pair of rabbits began to give birth to rabbits the second month after they were born , If there is no death within a year , Then a pair of rabbits a year (12 Months ) How many pairs can it breed ?( )
#include<stdio.h> int main() { long f1,f2; int i; f1=f2=1; for(i=1;i<=12;i++)
{ printf("i=%d f2=%ld\n",i,f2); f1=f2; f2=___; } return 0; }
A f2*2+f1
B f1+f2
C f1*2+f2
D f2-f1
Reference answer :B
5. The monkey picked some peaches on the first day , Eat half immediately , Not yet , Another one , The next morning, he ate half of the remaining peaches , Another one . After that, I ate half of the rest of the previous day and one more every morning . To the first 5 When you want to eat again in the morning , See, there's only one left 1 A peach . How many peaches did you pick on the first day .( )
#include<stdio.h> #define N 5 int main() { int n,s1,s2; s1=1;
for(n=N-1;n>=1;n--)// From the penultimate day { s2=___;// Count the peaches of the day s1=s2; }
printf(" The number of peaches on the first day is %4d\n",s2); return 0; }
A s1-s2/2
B s1*2+1
C (s1+1)*2
D s1+s2
Reference answer :C
The answer is for reference only , We should study hard C Language .
Technology