1.在?C?語言中(以 16位?PC?機為例),5種基本數據類型的存儲空間長度的順序為()
?A?.?char?<?int?<?long int <=float < double?
?B?.?char =?int?<?long int<=float <double
C?.?char?<?int < long int = float =double
?D?.?char =?int = long??int?<=?float?<?double?
2.已知學生記錄描述為
?struct student
{int no;
?char name?[20];
?char sex;
?struct?
{?int?year?;?
int montg;
int day;} birth;
}; struct??student? s;
設變量?s?中的"生日"應是"1984年11月?,下列對"生日"的正確賦值方式是
?A?.
?year=?1984;
?month =ll ;
day=11;
B.
?birth?.?year =1984:
?birth?.?month?=11;
?birth?.?day =11;
D.
?s?.?birth?.?year =1984;
?s?.?birth?.?month?=I1;
?s?.?birth?.?day?=1l;
C.
?s?.?year =1984;
?S?.?month?=?Il ;
?s?.?day?=?ll ;
3.當定義一個結構體變量時系統分配給它的內存是(
?A?.各成員所需內存量的總和
?b?.結構中第一個成員所需內存量
?C?.成員中占內存量最大者所需的容量
?d?.結構中最后一個成員所需內存量
4.在一個源文件中定義的全局變量的作用域為()。
?A?.本文件的全部范圍?
C?.本函數的全部范圍
?B?.從定義該變量開始至本文件結束
?D?.本程序的全部范圍
5.程序段
?int x =-1;
?do?
{?x?=?x?*?x?;
}(!?x?);
?A?.是死循環?B?.循環執行2次?C?.循環執行1次?D?.不合法
6.如果?int?*?px?,*?py?:則可用(?temp?=*?px?:*?px?=*?py?:*?py?-?temp?)實現*?px?和*?py?
的交換。其中?temp?應該說明為()。
?A?.?int?temp?
?B?.?int?&?temp?
?C?.?int?**?temp?
?D?.?int?*?temp
答案:ADA BDA
5.少了while
7.當執行下面的程序時,如果輸入?ABC?,則輸出是
#?include?<?stdio?.?h?>
#?include?<?string?.?h?>
main {
?char?ss?[10]="12345";
?gets?(?ss?);
?strcalt(?ss?,"6789"):
?printt?("%?s?",?ss?);
}
答案:ABC6789? ? ABC覆蓋了ss原有的
8.下面的函數?index?(?char?s?[],?char?t?[])是檢查字符串?s?中是否包含字符串?t?,若包含,則返回?t?在?s?中的開始位置(下標值),否則返回﹣1。請填空。
#?include?<?stdio?.?h?>
?index?(?char?s?[].?char?t?[])
?int?i?,?j?.?k?;
?for?(?i?=0;?s?[?i?]!=\0';?i?++)
?for?(?j?=?i?,?k?=0; ————————&&?s?[?j?]=t[?k?];?j?++,——————);
if(___________)
?return i;
}
return -1;
}
?
答案:1.t[k]!='\0'? ? ?2.k++? ? ? 3.t[k]=='\0'
9.? Π/4≈1-1/3+1/5-1/7+…公式求的近做值。直到某一項的絕對值小于1e-6為止
# inolude < stdio . h >
# include < math . h >void main()
{ int s ; //正負號float n ,t , pi ; //pi為和,t為項數,n為分母t =1, pi =0; n =1.0; s =1;while ( fabs ( t )>1e-6){pi = pi + t ;n = n +2;s =- S ;t = s / n ;
}pi = pi *4;printf (" pi =%10.6f\ n ", pi );
10.寫一個函數,使給定的一個4*4二維矩陣轉置,即行列互換,要求在主函數里完成鍵盤輸入和轉置后的打印輸出
# include < stdio . h >void zz ( int a [4][4])
{int t , i , j ;for ( i =0;i <4;i++)
for ( j =0;j<i;j++)t = a [ i ][ j];
a[i][j]=a[j][i];
a[j][i]=t;
}}void main()
{
int b[4][4],i,j;
for(i=0;i<4;i++)
{
for (j=0; j<4; j++)
{
scanf("d", &b[i][j]) ;
printf("%3d",b[i][j]);
}
printf("\n");
zz(b)
for(i=0;i<4;i++)
{
for (j=0;j<4;j++)
{
printf("%d\t", b[i][j]);
printf("\n");
}}
?