2016年計算機等級考試四級上機編程試題及答案
第一套
===============================================================================
試題説明 :
===============================================================================
已知在文件中存有若干個(個數<200)四位數字的正整數, 函數ReadDat( )是讀取這若干個正整數並存入數組xx中。請編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少個正整數totNum; 2.求出這些數中的各位數字之和是偶數的數的個數totCnt, 以及滿足此條件的這些數的算術平均值totPjz, 最後調用函數WriteDat()把所求的結果輸出到文件中。
注意: 部分源程序存放在PROG1.C中。
請勿改動主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
===============================================================================
程序 :
===============================================================================
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件中共有多少個正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數據文件不能打開!07n") ;
return ;
}
CalValue() ;
printf("文件中共有正整數=%d個n", totNum) ;
printf("符合條件的正整數的個數=%d個n", totCnt) ;
printf("平均值=%.2lfn", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("", "r")) == NULL) return 1 ;
while(!feof(fp)) {
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
fp = fopen("", "w") ;
fprintf(fp, "%dn%dn%.2lfn", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
===============================================================================
所需數據 :
===============================================================================
@2 016
6045,6192,1885,3580,8544,6826,5493,8415,3132,5841,
6561,3173,9157,2895,2851,6082,5510,9610,5398,5273,
3438,1800,6364,6892,9591,3120,8813,2106,5505,1085,
5835,7295,6131,9405,6756,2413,6274,9262,5728,2650,
6266,5285,7703,1353,1510,2350,4325,4392,7573,8204,
7358,6365,3135,9903,3055,3219,3955,7313,6206,1631,
5869,5893,4569,1251,2542,5740,2073,9805,1189,7550,
4362,6214,5680,8753,8443,3636,4495,9643,3782,5556,
1018,9729,8588,2797,4321,4714,9658,8997,2080,5912,
9968,5558,9311,7047,6138,7618,5448,1466,7075,2166,
4025,3572,9605,1291,6027,2358,1911,2747,7068,1716,
9661,5849,3210,2554,8604,8010,7947,3685,2945,4224,
7014,9058,6259,9503,1615,1060,7787,8983,3822,2471,
5146,7066,1029,1777,7788,2941,3538,2912,3096,7421,
9175,6099,2930,4685,8465,8633,2628,7155,4307,9535,
4274,2857,6829,6226,8268,9377,9415,9059,4872,6072,
#E
@3 $ 003
|160|91|5517.16
#E
第二套
===============================================================================
試題説明 :
===============================================================================
已知在文件中存有若干個(個數<200)四位數字的正整數, 函數ReadDat( )編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少個正整數totNum; 2.求出這些數中的各位數字之和是奇數的數的個數totCnt, 以及滿足此條件的這些數的算術平均值totPjz, 最後調用函數WriteDat()把所求的結果輸出到文件中。
注意: 部分源程序存放在PROG1.C中。
請勿改動主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
===============================================================================
程序 :
===============================================================================
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件中共有多少個正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數據文件不能打開!07n") ;
return ;
}
CalValue() ;
printf("文件中共有正整數=%d個n", totNum) ;
printf("符合條件的正整數的個數=%d個n", totCnt) ;
printf("平均值=%.2lfn", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("", "r")) == NULL) return 1 ;
while(!feof(fp)) {
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
fp = fopen("", "w") ;
fprintf(fp, "%dn%dn%.2lfn", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
===============================================================================
所需數據 :
===============================================================================
@2 016
6045,6192,1885,3580,8544,6826,5493,8415,3132,5841,
6561,3173,9157,2895,2851,6082,5510,9610,5398,5273,
3438,1800,6364,6892,9591,3120,8813,2106,5505,1085,
5835,7295,6131,9405,6756,2413,6274,9262,5728,2650,
6266,5285,7703,1353,1510,2350,4325,4392,7573,8204,
7358,6365,3135,9903,3055,3219,3955,7313,6206,1631,
5869,5893,4569,1251,2542,5740,2073,9805,1189,7550,
4362,6214,5680,8753,8443,3636,4495,9643,3782,5556,
1018,9729,8588,2797,4321,4714,9658,8997,2080,5912,
9968,5558,9311,7047,6138,7618,5448,1466,7075,2166,
4025,3572,9605,1291,6027,2358,1911,2747,7068,1716,
9661,5849,3210,2554,8604,8010,7947,3685,2945,4224,
7014,9058,6259,9503,1615,1060,7787,8983,3822,2471,
5146,7066,1029,1777,7788,2941,3538,2912,3096,7421,
9175,6099,2930,4685,8465,8633,2628,7155,4307,9535,
4274,2857,6829,6226,8268,9377,9415,9059,4872,6072,
#E
@3 $ 003
|160|69|5460.51
#E
第三套
===============================================================================
試題説明 :
===============================================================================
已知在文件中存有若干個(個數<200)四位數字的正整數, 函數ReadDat( )是讀取這若干個正整數並存入數組xx中。請編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少個正整數totNum; 2. 求這些數右移1位後, 產生的新數是奇數的數的個數totCnt, 以及滿足此條件的.這些數(右移前的值)的算術平均值totPjz, 最後調用函數WriteDat()把所求的結果輸出到文件中。
注意: 部分源程序存放在PROG1.C中。
請勿改動主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
===============================================================================
程序 :
===============================================================================
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件中共有多少個正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數據文件不能打開!07n") ;
return ;
}
CalValue() ;
printf("文件中共有正整數=%d個n", totNum) ;
printf("符合條件的正整數的個數=%d個n", totCnt) ;
printf("平均值=%.2lfn", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("", "r")) == NULL) return 1 ;
while(!feof(fp)) {
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
fp = fopen("", "w") ;
fprintf(fp, "%dn%dn%.2lfn", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
===============================================================================
所需數據 :
===============================================================================
@2 016
6045,6192,1885,3580,8544,6826,5493,8415,3132,5841,
6561,3173,9157,2895,2851,6082,5510,9610,5398,5273,
3438,1800,6364,6892,9591,3120,8813,2106,5505,1085,
5835,7295,6131,9405,6756,2413,6274,9262,5728,2650,
6266,5285,7703,1353,1510,2350,4325,4392,7573,8204,
7358,6365,3135,9903,3055,3219,3955,7313,6206,1631,
5869,5893,4569,1251,2542,5740,2073,9805,1189,7550,
4362,6214,5680,8753,8443,3636,4495,9643,3782,5556,
1018,9729,8588,2797,4321,4714,9658,8997,2080,5912,
9968,5558,9311,7047,6138,7618,5448,1466,7075,2166,
4025,3572,9605,1291,6027,2358,1911,2747,7068,1716,
9661,5849,3210,2554,8604,8010,7947,3685,2945,4224,
7014,9058,6259,9503,1615,1060,7787,8983,3822,2471,
5146,7066,1029,1777,7788,2941,3538,2912,3096,7421,
9175,6099,2930,4685,8465,8633,2628,7155,4307,9535,
4274,2857,6829,6226,8268,9377,9415,9059,4872,6072,
#E
@3 $ 003
|160|80|5537.54
#E 第四套
===============================================================================
試題説明 :
===============================================================================
已知在文件中存有若干個(個數<200)四位數字的正整數, 函數ReadDat( )是讀取這若干個正整數並存入數組xx中。請編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少個正整數totNum; 2. 求這些數右移1位後, 產生的新數是偶數的數的個數totCnt, 以及滿足此條件的這些數(右移前的值)的算術平均值totPjz, 最後調用函數WriteDat()把所求的結果輸出到文件中。
注意: 部分源程序存放在PROG1.C中。
請勿改動主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
===============================================================================
程序 :
===============================================================================
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件中共有多少個正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數據文件不能打開!07n") ;
return ;
}
CalValue() ;
printf("文件中共有正整數=%d個n", totNum) ;
printf("符合條件的正整數的個數=%d個n", totCnt) ;
printf("平均值=%.2lfn", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("", "r")) == NULL) return 1 ;
while(!feof(fp)) {
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
fp = fopen("", "w") ;
fprintf(fp, "%dn%dn%.2lfn", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
===============================================================================
所需數據 :
===============================================================================
@2 016
6045,6192,1885,3580,8544,6826,5493,8415,3132,5841,
6561,3173,9157,2895,2851,6082,5510,9610,5398,5273,
3438,1800,6364,6892,9591,3120,8813,2106,5505,1085,
5835,7295,6131,9405,6756,2413,6274,9262,5728,2650,
6266,5285,7703,1353,1510,2350,4325,4392,7573,8204,
7358,6365,3135,9903,3055,3219,3955,7313,6206,1631,
5869,5893,4569,1251,2542,5740,2073,9805,1189,7550,
4362,6214,5680,8753,8443,3636,4495,9643,3782,5556,
1018,9729,8588,2797,4321,4714,9658,8997,2080,5912,
9968,5558,9311,7047,6138,7618,5448,1466,7075,2166,
4025,3572,9605,1291,6027,2358,1911,2747,7068,1716,
9661,5849,3210,2554,8604,8010,7947,3685,2945,4224,
7014,9058,6259,9503,1615,1060,7787,8983,3822,2471,
5146,7066,1029,1777,7788,2941,3538,2912,3096,7421,
9175,6099,2930,4685,8465,8633,2628,7155,4307,9535,
4274,2857,6829,6226,8268,9377,9415,9059,4872,6072,
#E
@3 $ 003
|160|80|5447.93
#E 第五套
===============================================================================
試題説明 :
===============================================================================
已知在文件中存有若干個(個數<200)四位數字的正整數, 函數ReadDat( )是讀取這若干個正整數並存入數組xx中。請編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少個正整數totNum; 2. 求這些數中的個位數位置上的數字是3、6和9的數的個數totCnt, 以及滿足此條件的這些數的算術平均值totPjz, 最後調用函數WriteDat( )把所求的結果輸出到文件中。
注意: 部分源程序存放在PROG1.C中。
請勿改動主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
===============================================================================
程序 :
===============================================================================
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件中共有多少個正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("數據文件不能打開!07n") ;
return ;
}
CalValue() ;
printf("文件中共有正整數=%d個n", totNum) ;
printf("符合條件的正整數的個數=%d個n", totCnt) ;
printf("平均值=%.2lfn", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("", "r")) == NULL) return 1 ;
while(!feof(fp)) {
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
fp = fopen("", "w") ;
fprintf(fp, "%dn%dn%.2lfn", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
===============================================================================
所需數據 :
===============================================================================
@2 016
6045,6192,1885,3580,8544,6826,5493,8415,3132,5841,
6561,3173,9157,2895,2851,6082,5510,9610,5398,5273,
3438,1800,6364,6892,9591,3120,8813,2106,5505,1085,
5835,7295,6131,9405,6756,2413,6274,9262,5728,2650,
6266,5285,7703,1353,1510,2350,4325,4392,7573,8204,
7358,6365,3135,9903,3055,3219,3955,7313,6206,1631,
5869,5893,4569,1251,2542,5740,2073,9805,1189,7550,
4362,6214,5680,8753,8443,3636,4495,9643,3782,5556,
1018,9729,8588,2797,4321,4714,9658,8997,2080,5912,
9968,5558,9311,7047,6138,7618,5448,1466,7075,2166,
4025,3572,9605,1291,6027,2358,1911,2747,7068,1716,
9661,5849,3210,2554,8604,8010,7947,3685,2945,4224,
7014,9058,6259,9503,1615,1060,7787,8983,3822,2471,
5146,7066,1029,1777,7788,2941,3538,2912,3096,7421,
9175,6099,2930,4685,8465,8633,2628,7155,4307,9535,
4274,2857,6829,6226,8268,9377,9415,9059,4872,6072,
#E
@3 $ 003
|160|43|5694.58
#E
-
2017年計算機四級軟件測試工程師知識鞏固題
軟件測試工程師在一家軟件企業中擔當的是“質量管理”角色,及時糾錯及時更正,確保產品的正常運作。以下是小編整理的2017年計算機四級軟件測試工程師知識鞏固題,歡迎參考閲讀!單選題1.下列軟件屬性中,軟件產品首要滿足的應該是________。(A)功能需求(B)性能需求(C)...
-
2014年計算機四級考試數據庫精選真題
(1)為了保證程序能連續執行,CPU必須確定下一條指令的地址,起到這一作用的是A.指令寄存器B.狀態寄存器C.地址寄存器D.程序計數器(2)若或非門的`輸入變量為A和B,輸出變量為Y,則A和B分別為下述哪一種情況時,Y才為1?A)1,0B)0,1C)0,0D)1,1設(V,E)是一連通的無圈圖,V包...
-
2017年計算機四級《網絡工程師》鞏固練習題
備考四級《網絡工程師》考試科目時,大家要有針對性地進行復習,掌握重要知識點。下面是小編分享的2017年計算機四級《網絡工程師》鞏固練習題,歡迎大家練習!1關於HFC的描述中,錯誤的是使用調製解調技術B.上、下行信道的傳輸速率可以不同C.藉助有線電話網絡傳輸數據D....
-
2016年3月計算機四級信息安全工程師模擬試題
一、單項選擇題1、駐留在多個網絡設備上的程序在短時間內同時產生大量的請求消息衝擊某Web服務器,導致該服務器不堪重負,無法正常響應其他合法用户的請求,這屬於。A.網上衝浪B.中間人攻擊攻擊攻擊2、在使用了shadow口令的系統中,/etc/passwd和/etc/shadow兩個文件...