国产18禁黄网站免费观看,99爱在线精品免费观看,粉嫩metart人体欣赏,99久久99精品久久久久久,6080亚洲人久久精品

2016年計算機軟考程序員模擬試題及答案2

時間:2016-07-19 14:49:00   來源:無憂考網(wǎng)     [字體: ]
試題四

  閱讀下列函數(shù)說明和C函數(shù),將應(yīng)填入 n 處的字句寫在答題紙的對應(yīng)欄內(nèi)。

  [函數(shù)2.1說明]

  函數(shù)strcat(char s[], char t[])的功能是:將字符串t復(fù)制連接字符串s的尾部,并返回新

  字符串的首地址作為函數(shù)值。例如:若s=“abcd”,t=“efg”,則新字符串應(yīng)該是“abcdefg”。

  [函數(shù)2.1]

  char *strcat(char s[], char t[])

  { char *p;

  p = s + strlen(s)-1

  while( (1) ) {

  (2) ;

  }

  *p = ‘\0’;

  return s;

  }

  [函數(shù)2.2說明]

  函數(shù)f(char *str, char del)的功能是:將非空字符串str中的指定字符del刪除,形成一個

  新字符串仍存放在str所指內(nèi)存單元中。

  例如若str的值為“33123333435”,del的值為‘3’,調(diào)用此函數(shù)后,新字符串為:“1245”。

  [函數(shù)2.2]

  void f(char *str, char del)

  {

  int i, j, len;

  len=strlen(str);

  i=j=0;

  while(i  if ( (3) )

  (4) = str[i];

  i++;

  }

  (5) ;

  }

  試題五

  閱讀以下說明和C代碼,將應(yīng)填入 n 處的字句寫在答題紙的對應(yīng)欄內(nèi)。

  [說明]

  下面程序中函數(shù)fun的功能是:在含有10 個元素的s數(shù)組中查找數(shù),及數(shù)所在位置 (即,下標(biāo)值),數(shù)可能不止一個。數(shù)作為函數(shù)值返回,數(shù)的個數(shù)通過指針變量n傳回,所在位置由數(shù)組pos傳回。

  例如:

  若輸入 2 8 5 7 8 4 5 3 2 8

  則應(yīng)輸出:

  The max: 8

  Total: 3 //數(shù)出現(xiàn)次數(shù)

  The positions: 1 4 9

  #include

  #define M 10

  int fun(int *a, int *n, int pos[])

  { int i, k, max=-32767;

  (1)

  for(i=0; i  if( (2) ) max=a[i];

  for(i=0; i  if( (3) ) pos[k++]=i;

  *n=k;

  return max;

  }

  main()

  { int a[M], pos[M], i=0, j, n;

  printf("Enter 10 number :");

  for(i=0; i  j=fun( (5) );

  printf("The max: %d\n", j);

  printf("Total: %d",n);

  printf("The position:");

  for(i=0; i  printf("\n");

  }