CVTE测评题

CVTE测评题
CVTE测评题

题目1:素因子分解

#include

#include

void main()

{

int t = 0;

int k = 2;

int pt[40];

int n,q,r,i ; //Compute the factors of n by trial division printf("Please enter the value of n:");

scanf("%d",&n);

while (n != 1)

{ q = n / k; r = n % k;

if(r != 0)

{ if(q > k) { k++;}

else { pt[t++] = n; break; }

}

else { pt[t++] = k; n = q; }

}

for(i = 0; i < t; ++i)

{

printf("%d ",*(pt+i));

}

printf("\n");

}

题目2:求3000以内所有包含5和6 的数之和(例如506,650)

#include "stdio.h"

#include "string.h"

#include "stdlib.h"

void main(void){

int i,sum;

char str[5];

for(sum=0,i=5;i<3000;i++)

if(strchr(itoa(i,str,10),'5') && strchr(str,'6')){

sum+=i;

//printf("%d ",i);//打出来看看

}

printf("\nsum=%d\n",sum);

}

题目3:求解下面程序的运行结果是什么???(3667788)

#include

void main()

{

int c;

char aa[] = "12345";

char *p = aa;

while (*p)

{

c = *p; //此时c=49,50,51,52,53

switch (c - '2')

{

case 0:

case 1:

putchar(c + 4);

case 2:

putchar(c + 4);

break;

case 3:

putchar (c + 3);

break;

default :

putchar (c + 2);

break;

}

p++;

}

printf("\n");

}

题目4:已知数列如下:F[1]=1,F[2]=1,F[3]=3,F[4]=5,...,F[n]=F[n-1]+2*F[n-2],那么请问F[28]-F[10]=??

程序代码:

#include

int f(int n)

{

if (n == 1)

return 1;

else if (n == 2)

return 1;

else

return f(n - 1) + 2 * f(n - 2);

}

void main()

{

printf("%d\n", f(28) - f(10));

}

题目5:已知54个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围。从编号为3的人开始报数,数到5的那个人出列;他的下一个人又从1开始报数,数到5的那个人又出列;依此规律重复下去,最后剩下的一位编号为???

#include

#include

using namespace std;

void circle_sort(int n,int s,int m,int *p);

int main()

{

int n=54;//游戏总人数

int s=3;//起始编号

int m=5;//报数数值

int *p=new int[n];

circle_sort(n,s,m,p);

cout<

return 0;

}

void circle_sort(int n,int s,int m,int *p) {

for(int i=0;i

*(p+i)=i+1;

int *end=p+n-1;

int *temp=p+(s+m-2)%n;

int n1=n,s1=s,m1=m;

while(n1) {

cout<<*temp<<" ";

*temp=-1;

if(n1==1)

break;

while(m1)

{

if (temp==end)

temp=p;

else

temp++;

if(*temp!=-1)

m1--;

}

m1=m;

n1--;

}

}

题目6:模块A直接访问模块B的内部数据,则模块A和模块B的耦合类型为:( D) A.数据耦合 B.标记耦合 C.公共耦合 D.内容耦合

题目7:Android的IPC(进程通信)主要采用以下哪个?(C)

A.Socket

B.Pipe

C.Binder

D.Signal

题目8:在下列关于数据库概念“关系”的陈述中,错误的是()

A.表中任意两行的值不能相同

B.表中任意两列的值不能相同

C.行在表中的顺序无关紧要

D.列在表中的顺序无关紧要

题目9:下列说法正确的是()

A.派生类对象可以强制转换为基类对象

B.在任何情况下,基类对象都不能转换为派生类对象

C.接口不可以实例化,也不可以引用实现该接口类的对象

D.基类对象可以访问派生类的成员

题目10:程序的运行结果是什么???(011122)

#include

void main()

{

int i;

for (i=0;i<3;i++)

{

switch(i)

{

case 1:printf("%d",i);

case 2:printf("%d",i);

default:printf("%d",i);

}

}

}

题目11:程序的运行结果是什么???(compare)

#include

void main()

{

static char a[]="computer";

static char b[]="compare";

char *p=a;

char *q=b;

int j;

for (j=0;j<7;j++)

{

if (*(p+j)=*(q+j))

{

printf("%c",*(p+j));

}

}

}

题目12:某公司数据库密码规定为7位组成的字符串,存储之前,需要将其加密,加密算法为:依次将每个字符的ASCII码值乘以2,再加上10,若计算到的新字符的值等于115,则继续将其除以3,否则不进行除法运算。最后将该得到的新字符串中所有字符前后互换(第一位和最后一位,第二位和倒数第二位交换,依次交换),编程求字符串“1234567”加密后的字符串。为什么??

程序代码:(结果是xvtrpnl)

#include

#include

#include

#include

using namespace std;

void Encryption(char *str)

{

vector pStr(str,str+strlen(str));

vector::reverse_iterator it = pStr.rbegin();

for(;it!=pStr.rend();it++)

{

*it=(*it)*2+10;

if(*it>128)

*it /=3;

}

copy(pStr.rbegin(),pStr.rend(),str);

int main()

{

char s[8]="1234567";

cout<

Encryption(s);

cout<

return 0;

}

题目13:设二叉树的先序遍历序列和后序遍历序列正好相反,则该二叉树满足的条件是(B)

A.空域只有一个结点

B.高度等于其结点数

C.该二叉树是完全二叉树

D.所有结点无左右孩子

温馨提示:最后一道题是:请写下你对这次测评的感受是什么???(提前写,到时候粘贴)

相关主题
相关文档
最新文档