阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明1]
本程序输入一字符串,并将其中的大写字母变成小写字母。
[C函数1]
#include<stdio.h>
void main()
{ int i=0;
char s[120];
printf("Enter a string.\n");
scanf("%s",s);
while( (1) ){
if( (2) )
s[i]=s[i]-'A'+'a';
i++;
}
printf("%s\n",S);
}
[说明2]
本程序用二分法,在已按字母次序从小到大排序的字符数组list[len]中,查找字符c,若c在数组中,函数返回字符c在数组中的下标,否则返回-1。
[C函数2]
int search(char list[],char c,int len)
( intlow=0,high=len-1,k;
while( (3) );
k=(10w+high)/2;
if( (4) ) return k;
else if( (5) )high=k-1;
else low=k+1;
return -1;
}
阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内
[说明]
以下程序的功能时三角形、矩形和正方形的面积输出。
程序由5个类组成:areatest是主类,类Triangle,Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。
[Java程序]
public class areatest {
public static viod main(string args[]){
Figure[]Figures={
New triangle(2,3,3),new rectangle(5,8),new square(5)
};
for(int i=0; i<Figures.length;i++){
system.out.println(Figures+"area="+Figures.getarea());
}
}
}
public abstract class figure {
public abstract double getarea();
}
public class rectangle extends (1) {
double height;
double width;
public rectangle (double height,double width){
this.height=height;
this.width=width;
}
public string tostring(){
return"rectangle:height="+height+",width="+width+":";
}
public double getarea(){
return (2)
}
}
public class square exends (3)
{
public square(double width){
(4);
}
public string tostring(){
return"square:width="+width":";
}
}
public class triangle entends (5)
{
double la;
double lb;
double lc;
public triangle(double la,double lb,double lc){
this.la=la;this.lb=lb;this.lc=lc;
}
public string tostring()(
return"triangle:sides="+la+","+lb+","+lc+":";
}
public double get area(){
double s=(la+lb+lc)/2.0;
return math.sqrt(s*(s-la)*(s-lb)*(s-lc));
}
}
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
设一个环上有编号为0~n-1的n粒颜色不尽相同的珠子(每粒珠子颜色用字母表示,n粒珠子的颜色由输入的字符串表示)。从环上的某两粒珠子间剪开,则环上珠子形成一个序列然后按以下规则从序列中取走珠子:首先从序列左端取走所有连续的同色珠子;然后从序列右端在剩下的珠子中取走所有连续的同色珠子,两者之和为该剪开处可取走珠子的粒数。在不同位置剪开,能取走的珠子也不尽相同。
本程序所求的是在环上哪个位置剪开,按上述规则可取走的珠子粒数最多。程序中用数组存储字符串。例如:10粒珠子颜色对应字符串为“aaabbbadcc”,在0号珠子前剪开,序列为aaabbbadcc,从左端取走3粒a色珠子,从右端取走2粒c色珠子,共取走5粒珠子。若在3号珠子前剪开,即bbbadccaaa,共取走6粒珠子。
[C函数]
int count(char*s,int start,int end)
{inti,c=0,color=s[start],step=(start>end)?-1:1;
for(i=start;s[i]==color;i+=step){
if(step>0 && i>end || (1) ) break;
(2) ;
}
return c;
}
void main()
{ char t,s[120];
int i,j,C,len,maxc,cut=0;
printf("请输入环上代表不同颜色珠子字符串:");
scanf("%s",s );
len=strlen(s);
for(i=maxc=0;i<len;i++){ /*尝试不同的剪开方式*/
c=count(s,0,len-1);
if(c<len) C+=count( (3));
if(c>maxc){cut=i;maxc=c; )
/*数组s的元素循环向左移动一个位置*/
t=s[0];
for(j=1;i<len;i++) (4);
(5);
}
printf("在第%d号珠子前面剪开,可以取走%d个珠子.\n",cut,maxc);
}
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
下面程序实现十进制向其它进制的转换。
[C++程序]
#include"ioStream.h"
#include"math.h"
#include
typedef struct node {
int data;
node*next;
}Node;
Class Transform.
{
DUDlic:
void Trans(int d,int i); //d为数字;i为进制
void print();
private:
Node*top;
};
void Transform.:Trans(int d,int i)
{
int m,n=0;
Node*P;
while(d>0)
{
(1);
d=d/i;
p=new Node;
if(!n){
p->data=m;
(2);
(3);
n++;
}
else{
p->data=m;
(4);
(5);
}
}
}
void Transform.:print()
{
Node*P;
while(top!=NULL)
{
p=top;
if(p->data>9)
cout<<data+55;
else
cout<<data;
top=p->next;
delete p;
}
}
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
函数void diff(Node*A,Node*B,Node**r)的功能是:根据两个由整数按升序构成的单链表L1和L2(分别由A,B指向)构造一个单链表L3(由*r指向),要求L3中的所有整数都是L1,并且不是L2中的整数,还要求L3中的所有整数都两两不等。
[C函数]
#include<malloc.h>
typedef struct node {
int data;
struct node*next;
}Node;
void diff(Node*A,Node*B,Node**r)
{ int lastnum;
Node*P;
*r=NULL;
if(!A) return;
while((1)>
if(A->data<B->data)
{lastnum=A->data;
p=(Node*)malloc(sizeof(Node));
P->data=lastnum;
P->next=*r;
(2);
do
A=A->next;
while( (3) >;
}
else iffA->data>B->data)
B=B->next;
else{
(4);
lastnum=A->data;
while (A &&A->data==lastnum)A=A->next;
}
while(A){
lastnum=A->data;
p=(Node*)malloc(sizeof(Node));
P->data=lastnum;
(5);
*r=P;
while(A && A->data==lastnum) A=A->next;
}
}
阅读以下说明和流程图,回答问题将解答填入对应栏。
[说明]
本流程图实现采用递归函数来求一个整数数组中从元素0到元素n中的最小值。该算法思想是这样的,首先我们假设有一个求数组中最小元素的函数,然后,在求某一具有n的元素的数组的最小值时,只要求将前n-1的元素的最小值与第n个元素比较即可。不断地重复这一过程,直到数组中只剩下一个元素,那么它必定是最小值。
注:int min(int X,int y)为返回两数中最小数的函数。
int minInArray(int a[],int n)为返回数组中最小数的函数。
minA为数组中最小值。
[问题l]
将流程图的(1)~(4)处补充完整。
[问题2]
min()函数的定义为(5)。
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明1]
本程序输入一字符串,并将其中的大写字母变成小写字母。
[C函数1]
#include<stdio.h>
void main()
{ int i=0;
char s[120];
printf("Enter a string.\n");
scanf("%s",s);
while( (1) ){
if( (2) )
s[i]=s[i]-'A'+'a';
i++;
}
printf("%s\n",S);
}
[说明2]
本程序用二分法,在已按字母次序从小到大排序的字符数组list[len]中,查找字符c,若c在数组中,函数返回字符c在数组中的下标,否则返回-1。
[C函数2]
int search(char list[],char c,int len)
( intlow=0,high=len-1,k;
while( (3) );
k=(10w+high)/2;
if( (4) ) return k;
else if( (5) )high=k-1;
else low=k+1;
return -1;
}
高级经济师考试试题精选练习(1)
高级经济师考试模拟练习题之单选题(1
高级经济师考试试题精选练习(2)
高级经济师考试试题精选练习(3)
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟试题及答案
高级经济师考试试题及答案:单选练习题
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟题及答案练习(1)
高级经济师考试模拟题及答案练习(2)