华为认证 百分网手机站

华为认证考试题库(4)

时间:2017-05-12 11:17:29 华为认证 我要投稿

2016年华为认证考试题库

  ga[SUBWAY_A+5].link=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=SUBWAY_A+6;

  p->next=NULL;

  ga[SUBWAY_A+5].link->next=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=SUBWAY_A+8;

  p->next=NULL;

  ga[SUBWAY_A+9].link=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=14;

  p->next=NULL;

  ga[SUBWAY_A+9].link->next=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=14;

  p->next=NULL;

  ga[SUBWAY_A+10].link=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=SUBWAY_A+11;

  p->next=NULL;

  ga[SUBWAY_A+10].link->next=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=SUBWAY_A+1;

  p->next=NULL;

  ga[SUBWAY_A].link=p;

  p=(edgenode*)malloc(sizeof(edgenode));

  p->adjvex=SUBWAY_A+SUBWAY_B-2;

  p->next=NULL;

  ga[SUBWAY_A+SUBWAY_B-1].link=p;

  // 打印各邻接节点

  for(i=0;i

  printf("%s:",ga[i].name);

  edgenode *s;

  s=ga[i].link;

  while(s!=NULL){

  printf("->%s",ga[s->adjvex].name);

  s=s->next;

  }

  printf("\n");

  }

  }

  int main(){

  vexnode ga[MAX];

  creat(ga);

  int i;

  char str[2][10];

  while(scanf("%s%s",str[0],str[1])!=EOF){

  int temp=0;

  for(i=0;i

  ga[i].flag=true;

  if(!strcmp(str[0],ga[i].name))temp=i;

  }

  queueq;

  q.push(ga[temp]);

  ga[temp].flag=false;

  int count=0;

  int start=0;

  int end=1;

  bool find_flag=false;

  while(!q.empty()){

  if(find_flag) break;

  count++;

  printf("************************\n");

  printf("第%d层搜索:",count);

  int temp_end=end;

  while(start

  printf("%s",q.front().name);

  if(!strcmp(q.front().name,str[1])){

  find_flag=true;

  break;

  }

  edgenode *s;

  s=q.front().link;

  while(s!=NULL){

  if(ga[s->adjvex].flag){

  q.push(ga[s->adjvex]);

  ga[s->adjvex].flag=false;

  end++;

  //printf("%s ",ga[s->adjvex].name);

  }

  s=s->next;

  }

  q.pop();

  start++;

  }

  printf("\n");

  }

  printf("%d\n",count);

  }

  return 0;

  }

  14. 字串转换

  问题描述:

  将输入的字符串(字符串仅包含小写字母‘a’到‘z’),按照如下规则,循环转换后输出:a->b,b->c,…,y->z,z->a;若输入的字符串连续出现两个字母相同时,后一个字母需要连续转换2次。例如:aa 转换为 bc,zz 转换为 ab;当连续相同字母超过两个时,第三个出现的字母按第一次出现算。

  要求实现函数:

  void convert(char *input,char* output)

  【输入】 char *input , 输入的字符串

  【输出】 char *output ,输出的字符串

  【返回】 无

  #include

  #include

  #include

  void convert(char *input,char* output)

  {

  if(input==NULL)

  return;

  chartemp='\0';

  intlen_input=strlen(input);

  inti;

  intflag=0;

  for(i=0;i

  {

  if(input[i]!=temp)

  {

  output[i]=(input[i]-'a'+1)%26+'a';

  temp=input[i];

  flag=1;

  }

  else

  {

  if(flag==1)

  {

  output[i]=(input[i]-'a'+2)%26+'a';

  temp=input[i];

  flag=0;

  }

  else

  {

  output[i]=(input[i]-'a'+1)%26+'a';

  temp=input[i];

  flag=1;

  }

  }

  }

  output[i]='\0';

  }

  void main()

  {

  char*input="xyz";

  charoutput[256];

  // scanf("%s",input);

  convert(input,output);

  printf("%s\n",output);

  }

  15. 在给定字符串中找出单词( “单词”由大写字母和小写字母字符构成,其他非字母字符视为单词的间隔,如空格、问号、数字等等;另外单个字母不算单词);找到单词后,按照长度进行降序排序,(排序时如果长度相同,则按出现的顺序进行排列),然后输出到一个新的字符串中;如果某个单词重复出现多次,则只输出一次;如果整个输入的字符串中没有找到单词,请输出空串。输出的单词之间使用一个“空格”隔开,最后一个单词后不加空格。

  要求实现函数:

  void my_word(charinput[], char output[])

  【输入】 char input[], 输入的字符串

  【输出】 char output[],输出的字符串

  【返回】 无

  #include

  #include

  #include

  void my_word(char input[],charoutput[])

  {

  char *p;

  char *temp;

  char *word[10];

  int len_input=strlen(input);

  int i,j;

  char except[] = ",";

  char *blank = " ";

  i=0;

  for (i=0;i

  {

  if (input[i]<'A' || (input[i]>'Z'&&input[i]<'a') ||input[i]>'z')

  {

  input[i]=',';

  }

  }

  j=0;

  /*保存取出的单词*/

  p= strtok(input,except);

  while(NULL!=p)

  {

  word[j++]=p;

  p= strtok(NULL,except);

  }

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

  printf("%s",word[i]);

  /*对单词按照长度降序排序,冒泡法*/

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

  {

  for (j=1;j<5-i;j++)

  {

  if(strlen(word[j-1])

  {

  temp=word[j];

  word[j]=word[j-1];

  word[j-1]=temp;

  }

  }

  }

  /*删除相同单词*/

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

  {

  for(j=i+1;j<5;j++)

  {

  if(strcmp(word[i],word[j])==0)

  word[j]="\0";

  }

  }

  /*将单词连接起来输出*/

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

  {

  if (0==j)

  {

  strncpy(output,word[j],strlen(word[j])+1);

  }

  else

  {

  strcat(output,blank);

  strcat(output,word[j]);

  }

  }

  return ;

  }

  int main()

  {

  char input[] ="some local buses, some1234123drivers";

  printf("筛选之前的字符串:%s\n",input);

  char output[30];

  my_word(input,output);

  printf("筛选之后的字符串:%s",output);

  printf("\n");

  return 0;

  }

  16. 数组中数字都两两相同,只有一个不同,找出该数字:

  int findUnique(int* a, int len)

  {

  int i = 1;

  int temp =a[0];

  for(; i

  {

  temp= temp ^ a[i];

  }

  printf("%d", temp);

  }

  17.题目二:数组中数字两两相同,有两个不同,找出这两个:

  #include

  int a[] = {1,1,2,4,3,3,2,5};

  int findXorSum(int* a, int len)

  {

  int i = 0;

  int temp =0;

  for(; i

  {

  temp= temp ^ a[i];

  }

  return temp;

  }

  int findFirstBit1(int n)

  {

  int count =1;

  while(!( n &1))

  {

  n =n>>1;

  count++;

  }

  returncount;

  }

  int isBit1(int a, int count)

  {

  a= a >> count-1;

  return(a & 1);

  }

  void findTwoUnique(int* a, int len)

  {

  int i = 0;

  int m = 0, n= 0;

  int temp =findXorSum(a, len);

  int count =findFirstBit1(temp);

  for(; i

  {

  if(isBit1(a[i],count))

  {

  m= m ^ a[i];

  }

  else

  {

  n= n ^ a[i];

  }

  }

  printf("%d,%d", m, n);

  }

  int main()

  {

  findTwoUnique(a,8);

  }

  18. 链表翻转。给出一个链表和一个数k,比如链表1→2→3→4→5→6,k=2,则翻转后2→1→4→3→6→5,若k=3,翻转后3→2→1→6→5→4,若k=4,翻转后4→3→2→1→5→6,用程序实现

  思想:采用遍历链表,分成length/k组,对每组进行逆转,逆转的同时要将逆转后的尾和头连接起来

更多相关文章推荐阅读:

1.2016年华为认证考试题库

2.2016年华为hcie认证考试题库

3.2016年华为认证认证试题(笔试)

4.2016年华为认证考试题及答案

5.2016年华为上机考试题

6.2016年华为HCDA认证考试题库

7.2016年华为笔试题及及答案

8.2016年华为笔试面试题及答案

9.2016年华为HCDA认证考试笔试题及答案