华为认证 百分网手机站

华为认证考试题库(2)

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

2016年华为认证考试题库

  }LinkList;

  LinkList *create(int n)

  {

  LinkList*p,*q,*head;

  inti=1;

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

  p->data=i;

  head=p;

  for(i=1;i<=n;i++)

  {

  q=(LinkList*)malloc(sizeof(LinkList));

  q->data=i+1;

  p->next=q;

  p=q;

  }

  p->next=head; //使链表尾连接链表头,形成循环链表

  returnhead;

  free(p);

  p=NULL;

  free(q);

  q=NULL;

  }

  void deletefun(LinkList *L,int m)

  {

  LinkList*p,*q,*temp;

  inti;

  p=L;

  while(p->next!=p)

  {

  for(i=1;i

  {

  q=p;

  p=p->next;

  }

  printf("%5d",p->data);

  temp=p;

  q->next=p->next;

  p=p->next;

  free(temp);

  }

  printf("%5d\n",p->data);

  }

  int main()

  {

  intn=7,m=3;

  LinkList*head1;

  head1=create(n);

  deletefun(head1,m);

  return0;

  }

  7..输入一串字符,只包含“0-10”和“,”找出其中最小的数字和最大的数字(可能不止一个),输出最后剩余数字个数。如输入 “3,3,4,5,6,7,7”

  #include

  #include

  #include

  void main()

  {

  charstr[100];

  printf("输入一组字符串:\n");

  scanf("%s",&str);

  intlen=strlen(str);

  intarray[100];

  intcount=0;

  for(inti=0;i

  {

  if(str[i]>='0'&&str[i]<='9')

  array[count++]=str[i]-'0';

  }

  array[count]='\0';

  intresult=count;

  intmin=array[0];

  intmax=array[0];

  for(intj=0;j

  {

  if(max

  max=array[j];

  elseif(min>array[j])

  min=array[j];

  }

  for(intk=0;k

  {

  if(array[k]==min)

  result--;

  if(array[k]==max)

  result--;

  }

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

  }

  8.输入一组身高在170到190之间(5个身高),比较身高差,选出身高差最小的两个身高;若身高差相同,选平均身高高的那两个身高;从小到大输出;

  如 输入 170 181173 186 190 输出 170 173

  #include

  #include

  #define N 5

  int main()

  {

  intHeight[N];

  intdmin;

  intH1,H2;

  inti,j,temp;

  printf("请输入一组身高在170到190之间的数据(共5个):\n");

  for(intk=0;k

  scanf("%d",&Height[k]);

  printf("\n");

  for(i=0;i

  for(j=1;jHeight[j];j++)

  {

  temp=Height[j-1];

  Height[j-1]=Height[j];

  Height[j]=temp;

  }

  H1=Height[0];

  H2=Height[1];

  dmin=H2-H1;

  for(intm=2;m

  {

  if(Height[m]-Height[m-1]<=dmin)

  {

  H1=Height[m-1];

  H2=Height[m];

  dmin=Height[m]-Height[m-1];

  }

  }

  printf("身高差最小的两个身高为:\n");

  printf("%d,%d\n",H1,H2);

  return0;

  }

  9. 删除子串,只要是原串中有相同的子串就删掉,不管有多少个,返回子串个数。

  #include

  #include

  #include

  #include

  int delete_sub_str(const char *str,constchar *sub_str,char *result)

  {

  assert(str!= NULL && sub_str != NULL);

  constchar *p,*q;

  char*t,*temp;

  p= str;

  q= sub_str;

  t= result;

  intn,count = 0;

  n= strlen(q);

  temp= (char *)malloc(n+1);

  memset(temp,0x00,n+1);

  while(*p)

  {

  memcpy(temp,p,n);

  if(strcmp(temp,q)== 0 )

  {

  count++;

  memset(temp,0x00,n+1);

  p= p + n;

  }

  else

  {

  *t= *p;

  p++;

  t++;

  memset(temp,0x00,n+1);

  }

  }

  free(temp);

  returncount;

  }

  void main()

  {

  chars[100] = {‘\0’};

  intnum = delete_sub_str(“123abc12de234fg1hi34j123k”,”123”,s);

  printf(“Thenumber of sub_str is %d\r\n”,num);

  printf(“Theresult string is %s\r\n”,s);

  }

  10. 要求编程实现上述高精度的十进制加法。要求实现函数:

  void add (const char *num1,const char *num2, char *result)

  【输入】num1:字符串形式操作数1,如果操作数为负,则num1[0]为符号位'-'

  num2:字符串形式操作数2,如果操作数为负,则num2[0]为符号位'-'

  【输出】result:保存加法计算结果字符串,如果结果为负,则result[0]为符号位。

  #include

  #include

  #include

  void move(char *str, int length) //移除字母前的"-"符号

  {

  if(str[0] != '-')

  return;

  int i;

  for(i = 0; i < length-1; i++)

  str[i] = str[i+1];

  str[i] = '\0';

  }

  intremove_zero(char *result, int length)

  {

  int count = 0;

  for(int i = length-1; i > 0; i--) //从最后开始移除0,直到遇到非0数字,只对最初位置上的0不予判断

  {

  if(result[i] == '0')

  {

  result[i] = '\0';

  count++;

  }else

  return length-count;

  }

  return length - count;

  }

  voidreverse(char *result, int length) //将字符串倒转

  {

  char temp;

  for(int i = 0; i <= (length-1)/2; i++)

  {

  temp = result[i];

  result[i] = result[length-1-i];

  result[length-1-i] = temp;

  }

  }

  intreal_add(char *str1, char *str2, char *result, const bool flag)

  {

  int len1 = strlen(str1);

  int len2 = strlen(str2);

  int n1, n2, another = 0; //another表示进位

  int cur_rs = 0; //表示result的当前位数

  int i, j;

  int curSum;

  for(i = len1-1, j = len2-1; i >= 0 && j >= 0; i--, j--)

  {

  n1 = str1[i] - '0';

  n2 = str2[j] - '0';

  curSum = n1 + n2 + another;

  result[cur_rs++] = curSum % 10 + '0';

  another = curSum / 10;

  }

  if(j < 0)

  {

  while(i >= 0) //遍历str1剩余各位

  {

  n1 = str1[i--] - '0';

  curSum = n1 + another;

  result[cur_rs++] = curSum % 10 + '0';

  another = curSum / 10;

  }

  if(another != 0) //如果还有进位未加上

  result[cur_rs++] = another + '0';

  }

  else

  {

  while(j >= 0)

  {

  n2 = str2[j--] - '0';

  curSum = n2 + another;

  result[cur_rs++] = curSum % 10 + '0';

  another = curSum / 10;

  }

  if(another != 0)

  result[cur_rs++] = another + '0';

  }

  result[cur_rs] = '\0';

  cur_rs = remove_zero(result, cur_rs);

  if(!flag)

  {

  result[cur_rs++] = '-';

  result[cur_rs] = '\0';

  }

  reverse(result, strlen(result));

  return cur_rs;

  }

  intreal_minus(char *str1, char *str2, char *result) //使用str1减去str2

  {

  char big[100], small[100];

  int big_len, sml_len;

  int len1 = strlen(str1);

  int len2 = strlen(str2);

  bool flag = false; //用于标记str2是否比str1大

  if(len1 < len2)

  flag = true;

  else if(len1 == len2)

  {

  if(strcmp(str1, str2) == 0)

  {

  result[0] = '0';

  result[1] = '\0';

  return 1;

  }else if(strcmp(str1,str2) < 0)

  flag = true;

  }

  if(flag) //将str1和str2交换,确保str1指向的值是其中较大者,最后通过flag确定要不要给前面加-号

  {

  char *temp = str1;

  str1 = str2;

  str2 = temp;

  len1 = strlen(str1);

  len2 = strlen(str2);

  }

  int n1, n2, another = 0; //another表示是否有借位

  int i, j;

  int cur_rs = 0;

  int curMinus;

  for(i = len1-1, j =len2-1; i>=0 && j>=0; i--,j--)

  {

  n1 = str1[i] - '0';

更多相关文章推荐阅读:

1.2016年华为认证考试题库

2.2016年华为hcie认证考试题库

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

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

5.2016年华为上机考试题

6.2016年华为HCDA认证考试题库

7.2016年华为笔试题及及答案

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

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