皮皮学,免费搜题
登录
搜题
【简答题】
阅读以下说明和C语言程序,将应填入(n)处的字句写在对应栏内。 【说明】 Fibonacci数列A={1,1,2,2,5,8,…)有如下性质: a0=a1=1 ai=ai-1+ai-2,i>1 对于给定的n,另外有一个由n个元素组成的数列xn,该数列中各元素的值为: xi=ai/ai+1,i=0,1,…,n 现要求对xn中的元素按升序进行排序,然后以分数形式输出排序后的xn。例如n=5时,排序前的xn={1/1,1/2,2/3,3/5,5/8},排序后的xn={1/2,3/5,5/8,2/3,1/1}。函数make()首先生成排序前的xn,然后调用函数sort()进行排序,最后输出所求结果。 【程序】 include <stdio.h> include <stdlib.h> include <malloc.h> struct fact { long m,n; }; void sort(int n,struct fact *p) { int a; long s,t,u,v; struct fact *q,*end; for(end=p+(n-1),a=1;a;end--) for(a=0,q=p;q<end;p++) { s=q->m; t=q->n; u=(q+1)->m; v=(q+1)->n; if( (1) ) { q->m=u; (2) (3) (q+1)->n=t; a=1; } } } void make(int n) { int i; long a,b,c; struct fact *x,*y; x=(struct fact *)malloc(sizeof(struct fact)*n); x->m=1: x->n=1; for(a=1,b=1,i=2;i<=n;i++) { (4) a=b; b=c; (x+(i-1))->m=a; (x+(i-1))->n=b; } (5) printf('x%d={%1d/%1d',n,x->m,x->n); for(y=x+1;y<x+n;y++) printf(',%1d/%1d',y->m,y->n); printf('}/n'); free(x); } void main() { int n; printf('input n:'); scanf('%d',&n); make(n); }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【单选题】听力原文: When cars first started appearing on the streets of the world, few people took them seriously. They were toys--playthings for grown men who didn't have much to do. No one thought that the automo...
A.
The two models of cars.
B.
The history of car industry.
C.
The development of cars in America.
D.
The structure of Duesenberg cars.
【单选题】When was the first car in the world bulit?
A.
1769
B.
1876
C.
1886
D.
1896
【单选题】He asked me .
A.
who did kick the first goal in the World Cup
B.
when was the APEC meeting held
C.
when China became a member of the WTO
D.
where will the 2008 Olympics be held
【简答题】New York: when the first jet struck, World Trade Center at 8:48 am on Tuesday, the People in 2 World Trade Center with a view of the instant damage across the divide had the clearest sense of what the...
【单选题】He asked me _____. [     ]
A.
who did kick the first goal in the World Cup
B.
when was the APEC meeting held
C.
when China became a member of the WTO
D.
when will the 2012 Olympics be held
【单选题】When was the deadly avian flu first discovered in humans in the world?
A.
1997.
B.
1998.
C.
2003.
D.
2004.
【单选题】When the first English settlers arrived in the New World, the Indians _______ jewelry made of animal bones greeted them warmly.
A.
wearing
B.
to wear
C.
worn
D.
having worn
【单选题】朊病毒对动物的感染过程属于(2014真题上11)
A.
急性感染
B.
潜伏感染
C.
慢性感染
D.
慢发病毒感染
E.
迟发性临诊症状的急性感染
【单选题】When is the first email in the world?
A.
1984
B.
1971
C.
2000
【单选题】When personal computers first began showing up in offices around the world, people believed that this business tool would lead to something called the 'paperless office.' This was hailed as a great ad...
A.
Selling computers
B.
Desktop publishing
C.
The 'paperless office'
D.
World problems
相关题目: