【收藏】一套基礎的C語言筆試題

論壇裏面一套基礎的C語言筆試題

 

每個5分共100分。錯選、多選、少選或不選均不得分。


1.[單選題]一個C程序的執行是從( A )
A:本程序的main函數開始,到main函數結束
B:本程序文件的第一個函數開始,到本程序文件的最後一個函數結束
C:本程序的main函數開始,到本程序文件的最後一個函數結束
D:本程序文件的第一個函數開始,到本程序main函數結束


2.[單選題]在C語言中,要求運算數必須是整型的運算符是( D )
A:/
B:++
C:!=
D:%


3.[單選題]C語言中,邏輯"真"等價於( C )
A:大於零的數
B:大於零的整數
C:非零的數
D:非零的整數


4.[單選題]若希望當A的值爲奇數時,表達式的值爲"真",A的值爲偶數時,表達式的值爲"假"。則以下不能滿足要求的表達式爲( C )
A:A%2 == 1
B:! (A%2==0)
C:! (A%2)
D:A%2


5.[單選題]以下程序的運行結果是( B )。
int main( void ){
int m = 5;
if ( m++ > 5) printf("%d/n", m);
else printf("%d/n", --m);
}
A:4
B:5
C:6
D:7


6.[單選題]以下對一維整型數組a的正確說明是( D )
A:int a(10)
B:int n = 10, a[n]
C:int n
scanf("%d", &n)
int a[n]
D:#define SIZE 10
int a[SIZE]

 

7.[單選題]若有說明:int a[3][4];則對a數組元素的非法引用是( D )
A:a[0][2*1]
B:a[1][3]
C:a[4-2][0]
D:a[0][4]

 

8.[單選題]若二維數組a有m列,則計算任一元素a[i][j]在數組中位置的公式爲( A )
A:i * m + j
B:j * m + i
C:i * m + j - 1
D:i * m + j + 1

 

9.[單選題]以下程序的功能是將字符串s中所有的字符c刪除,那麼空白處缺少的語句爲:( A )。
#include
int main(void)
{
char s[80] ;
int i, j ;
gets(s) ;
for ( i = j = 0 ; s [i] != ‘/0' ; i++ )
if ( s [i] != ‘c' )
;
s [ j ] = ‘/0' ;
puts ( s ) ;
return 0 ;
}
A: s [ j++] = s [ i ]
B:s [ ++j ] = s [ i ]
C:s [ j ] = s [ i ]; j++
D:s [ j ] = s [ i ]

 

10.[單選題]下面程序的功能是將已按升序排好序的兩個字符串a和b中的字符,按升序歸併到字符串c中,請爲程序中的空白處選擇適當的語句。 第一空答案( A )
#include
int main(void)
{
char a[ ] = "acegikm";
char b[ ] = "bdfhjlnpq";
char c[80], *p;
int i = 0, j= 0, k = 0;
while( a[i] != '/0' && b[j] != ‘/0' )
{
if ( a[i] < b[j] ) { ( ① ) }
else { ( ② ) }
k++;
}
c[k] = ‘/0';
if ( ③ ) p = b + j;
else p = a + i;
strcat ( c , p );
puts ( c );
}
A:c[k] = a[i]; i++
B:c[k] = b[j]; i++
C:c[k] = a[i]; j++
D:c[k] = a[j]; j++

 

11.[單選題]下面程序的功能是將已按升序排好序的兩個字符串a和b中的字符,按升序歸併到字符串c中,請爲程序中的空白處選擇適當的語句。第二空答案( D )
#include
int main(void)
{
char a[ ] = "acegikm";
char b[ ] = "bdfhjlnpq";
char c[80], *p;
int i = 0, j= 0, k = 0;
while( a[i] != '/0' && b[j] != ‘/0' )
{
if ( a[i] < b[j] ) { ( ① ) }
else { ( ② ) }
k++;
}
c[k] = ‘/0';
if ( ③ ) p = b + j;
else p = a + i;
strcat ( c , p );
puts ( c );
}
A:c[k] = a[i]; i++
B:c[k] = b[j]; i++
C:c[k] = a[i]; j++
D:c[k] = b[j]; j++

 

12.[單選題]在一個C源程序文件中,若要定義一個只允許本源文件中所有函數使用的全局變量,則該變量需要使用的存儲類別是( D )
A:extern
B:register
C:auto
D:static

 

13.[單選題]以下程序的正確運行結果是( D )。
#include
int f(int a);
int main(void)
{
int a = 2, i;
for( i = 0; i < 3; i++ ) printf("%4d",f(a));
}
int f(int a)
{
int b = 0;
static int c = 3;
b++; c++;
return(a+b+c);
}
A:7 7 7
B:7 10 13
C:7 9 11
D:7 8 9

 

14.[單選題]以下程序的運行結果爲( B )。
void sub(int x, int y, int *z)
{ *z = y - x ; }
int main(void)
{
int a,b,c ;
sub(10, 5, &a) ;
sub(7, a, &b) ;
sub(a, b, &c) ;
printf( "%4d,%4d, %4d/n",a,b,c);
}
A:5, 2, 3
B:-5, -12, -7
C:-5, -12, -17
D:5, -2, -7

 

15.[單選題]有如下語句int a = 10, b = 20, *p1, *p2; p1 = &a; p2 = &b;變量與指針的關係如圖1所示;若要實現圖2所示的存儲結構,可選用的賦值語句爲( 沒圖 可能是 B或A )
A:*p1 = *p2
B:p1 = p2
C:p1 = *p2
D:*p1 = p2

 

16.[單選題]若已建立下面的鏈表結構,指針p、q分別指向圖中所示結點,則不能將q所指的結點插入到鏈表末尾的一組語句是( )
A:q -> next = NULL; p = p -> next; p -> next = q
B:p = p -> next; q -> next = p -> next; p -> next = q
C:p = p -> next; q -> next = p; p -> next = q
D:p = (*p).next; (*q).next = (*p).next; (*p).next = q

 

17.[單選題]以下程序的功能是:讀入一行字符(如:a,b,... y,z),按輸入時的逆序建立一個鏈接式的結點序列,即先輸入的位於鏈表尾(如下圖),然後再按輸入的相反順序輸出,並釋放全部結點。請在空白處爲程序選擇適當的代碼。 第一空答案( B )
#include 
#define getnode(type) ① malloc(sizeof(type))
int main(void)
{
  struct node{
      char info;
      struct node *link;
   }*top,*p;
   char c;
   top = NULL;
   while( ( c = getchar( ) ② )
   {
         p = getnode ( struct node );
         p -> info = c;
         p -> link = top; 
         top = p;
   }
   while ( top )
  {
       ③ ;
       top = top -> link;
       putchar ( p -> info );
       free ( p );
   }
}
A:(type)
B:(type *)
C:type
D:type *

 

18.[單選題]以下程序的功能是:讀入一行字符(如:a,b,... y,z),按輸入時的逆序建立一個鏈接式的結點序列,即先輸入的位於鏈表尾(如下圖),然後再按輸入的相反順序輸出,並釋放全部結點。請在空白處爲程序選擇適當的代碼。第二空答案(D )

#include 
#define getnode(type) ① malloc(sizeof(type))
int main(void)
{
  struct node{
      char info;
      struct node *link;
   }*top,*p;
   char c;
   top = NULL;
   while( ( c = getchar( ) ② )
   {
         p = getnode ( struct node );
         p -> info = c;
         p -> link = top; 
         top = p;
   }
   while ( top )
  {
       ③ ;
       top = top -> link;
       putchar ( p -> info );
       free ( p );
   }
}
A:=='/0'
B:!='/0'
C:=='/n'
D:!='/n'

 

19.[單選題]以下程序的功能是:讀入一行字符(如:a,b,... y,z),按輸入時的逆序建立一個鏈接式的結點序列,即先輸入的位於鏈表尾(如下圖),然後再按輸入的相反順序輸出,並釋放全部結點。請在空白處爲程序選擇適當的代碼。第三空答案( B)

#include
#define getnode(type) ① malloc(sizeof(type))
int main(void)
{
  struct node{
      char info;
      struct node *link;
   }*top,*p;
   char c;
   top = NULL;
   while( ( c = getchar( ) ② )
   {
         p = getnode ( struct node );
         p -> info = c;
         p -> link = top; 
         top = p;
   }
   while ( top )
  {
       ③ ;
       top = top -> link;
       putchar ( p -> info );
       free ( p );
   }
}
A:top = p
B:p = top
C:p == top
D:top == p

 

20.[單選題]以下程序的輸出結果是( C )
#include
#define M 5
#define N M+M
main()
{

    int k;
    k=N*N*5; printf("%d/n",k);
}


A:500
B:125
C:55
D:100

發佈了62 篇原創文章 · 獲贊 10 · 訪問量 32萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章