江苏省计算机等级考试试题库系统
{return x*(3*x*(x-1)+1)-1;} float f1(float x) {return 9*x*x-6*x+1;} float newtoon(float x) { float f,fl,xO; do
{ ___(21)_________ ; f=f(xO); f1=F1(xO);
x= ______(22)______ ; }while(fabs(x-xO)>1e-5); return x; } main() { float xO; scanf(\,,&x0);
prinff(’\.2f\\n\,newtoon(x0)); }
15.程序功能:选票统计。二维数组s中保存了投票后10张有效选票上所填写的候选人姓名,结构数组stat中保存统计结果。程序运行后的输出结果是\:2 wang:5 zhao:3\。 #include
{char name[20]; /女候选人姓名}/ int count; /女候选人得票数}/ }COUNT;
int count(char x[][20],int n, ______(23)___________) {int i,j,k=0;
for(i=0;____ (24)__________;i++) { for(j=0;j if(strcmp(st[j].name,x[i])==0) { __________(25)_______ ; break; } if(j>=k) { ________(26)_____________; st[k].count++; k++: } } return k; } main() {char s[10][20]={\,\,\; COUNT stat[5]={0}; - 6 - 江苏省计算机等级考试试题库系统 int i,n;. n=count(S,10,stat); for(i=0;i printf(\,stat[i].name,stat[i].count); } 16.设一个单向链表结点的数据类型定义为: struct node { int x; struct node *next; }; fun函数从h指向的链表第二个结点开始遍历所有结点,当遇到x值为奇数的结点时,将该结点移到h链表第一个结点之前,函数返回链表首结点地址。print函数输出p指向的链表中所有结点的x值。程序运行后的输出结果是\。 #include struct node *next; }; void print(stmct node *p) { while_____(27)________ {printf(\, _________(28)_______);P=P->next;} prinff(\; } struct node *fun(struct node *h) { struct node *pl,*p2,*p3; pl=h;p2=pl->next; while(p2) { if(p2->x%2) {p3=p2; pl->next=_______(29)_________ ; p2=pl->next: p3->next=h; ________(30)___________; } else {pl=p2:p2=p2->next;} } retnm h; } main() {struct node a[N]={{4},{3},{2},{1}},*head=a;int i,num; for(i=0;i head=fun(head);print(head); } - 7 -