全国计算机二等级1800值得吗,全国计算机等级考试四级上机编程题型二

第六套

===============================================================================

试题说明 :

===============================================================================

已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中。请编制函数CalValue( ), 其功能要求: 1. 求出这文件中共有多少个正整数totNum; 2. 求这些数中的十位数位置上的数字是2、4和8的数的个数totCnt, 以及满足此条件的这些数的算术平均值totPjz, 最后调用函数WriteDat( )把所求的结果输出到文件OUT6.DAT中。

注意: 部分源程序存放在PROG1.C中。

请勿改动主函数main( )、读数据函数ReadDat()和输出数据

函数WriteDat()的内容。

===============================================================================

程序 :

===============================================================================

#include

#include

#define MAXNUM 200

int xx[MAXNUM] ;

int totNum = 0 ; /* 文件IN.DAT中共有多少个正整数 */

int totCnt = 0 ; /* 符合条件的正整数的个数 */

double totPjz = 0.0 ; /* 平均值 */

int ReadDat(void) ;

void WriteDat(void) ;

void CalValue(void)

{

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\007\n") ;

return ;

}

CalValue() ;

printf("文件IN.DAT中共有正整数=%d个\n", totNum) ;

printf("符合条件的正整数的个数=%d个\n", totCnt) ;

printf("平均值=%.2lf\n", totPjz) ;

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

if((fp = fopen("in.dat", "r")) == NULL) return 1 ;

while(!feof(fp)) {

fscanf(fp, "%d,", &xx[i++]) ;

}

fclose(fp) ;

return 0 ;

}

void WriteDat(void)

{

FILE *fp ;

fp = fopen("OUT6.DAT", "w") ;

fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

fclose(fp) ;

}

===============================================================================

所需数据 :

===============================================================================

@2 IN.DAT 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 $OUT6.DAT 003

|160\|45\|5229.16

#E

第七套

===============================================================================

试题说明 :

===============================================================================

已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中。请编制函数CalValue( ), 其功能要求: 1. 求出这文件中共有多少个正整数totNum; 2. 求这些数中的百位数位置上的数字是1、5和7的数的个数totCnt, 以及满足此条件的这些数的算术平均值totPjz, 最后调用函数WriteDat( )把所求的结果输出到文件OUT7.DAT中。

注意: 部分源程序存放在PROG1.C中。

请勿改动主函数main( )、读数据函数ReadDat()和输出数据

函数WriteDat()的内容。

===============================================================================

程序 :

===============================================================================

#include

#include

#define MAXNUM 200

int xx[MAXNUM] ;

int totNum = 0 ; /* 文件IN.DAT中共有多少个正整数 */

int totCnt = 0 ; /* 符合条件的正整数的个数 */

double totPjz = 0.0 ; /* 平均值 */

int ReadDat(void) ;

void WriteDat(void) ;

void CalValue(void)

{

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\007\n") ;

return ;

}

CalValue() ;

printf("文件IN.DAT中共有正整数=%d个\n", totNum) ;

printf("符合条件的正整数的个数=%d个\n", totCnt) ;

printf("平均值=%.2lf\n", totPjz) ;

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

if((fp = fopen("in.dat", "r")) == NULL) return 1 ;

while(!feof(fp)) {

fscanf(fp, "%d,", &xx[i++]) ;

}

fclose(fp) ;

return 0 ;

}

void WriteDat(void)

{

FILE *fp ;

fp = fopen("OUT7.DAT", "w") ;

fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

fclose(fp) ;

}

===============================================================================

所需数据 :

===============================================================================

@2 IN.DAT 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 $OUT7.DAT 003

|160\|47\|5448.32

#E

第八套

===============================================================================

试题说明 :

===============================================================================

已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中。请编制函数CalValue( ), 其功能要求: 1. 求出这文件中共有多少个正整数totNum; 2. 求这些数中的千位数位置上的数字大于个位数位置上的数字的数的个数totCnt, 以及满足此条件的这些数的算术平均值totPjz, 最后调用函数WriteDat()把所求的结果输出到文件OUT8.DAT中。

注意: 部分源程序存放在PROG1.C中。

请勿改动主函数main( )、读数据函数ReadDat()和输出数据

函数WriteDat()的内容。

===============================================================================

程序 :

===============================================================================

#include

#include

#define MAXNUM 200

int xx[MAXNUM] ;

int totNum = 0 ; /* 文件IN.DAT中共有多少个正整数 */

int totCnt = 0 ; /* 符合条件的正整数的个数 */

double totPjz = 0.0 ; /* 平均值 */

int ReadDat(void) ;

void WriteDat(void) ;

void CalValue(void)

{

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\007\n") ;

return ;

}

CalValue() ;

printf("文件IN.DAT中共有正整数=%d个\n", totNum) ;

printf("符合条件的正整数的个数=%d个\n", totCnt) ;

printf("平均值=%.2lf\n", totPjz) ;

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

if((fp = fopen("in.dat", "r")) == NULL) return 1 ;

while(!feof(fp)) {

fscanf(fp, "%d,", &xx[i++]) ;

}

fclose(fp) ;

return 0 ;

}

void WriteDat(void)

{

FILE *fp ;

fp = fopen("OUT8.DAT", "w") ;

fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

fclose(fp) ;

}

===============================================================================

所需数据 :

===============================================================================

@2 IN.DAT 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 $OUT8.DAT 003

|160\|81\|6617.44

#E

第九套

===============================================================================

试题说明 :

===============================================================================

已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中。请编制函数CalValue( ), 其功能要求: 1. 求出这文件中共有多少个正整数totNum; 2. 求这些数中的百位数位置上的数字小于十位数位置上的数字的数的个数totCnt, 以及满足此条件的这些数的算术平均值totPjz, 最后调用函数WriteDat()把所求的结果输出到文件OUT9.DAT中。

注意: 部分源程序存放在PROG1.C中。

请勿改动主函数main( )、读数据函数ReadDat()和输出数据

函数WriteDat()的内容。

===============================================================================

程序 :

===============================================================================

#include

#include

#define MAXNUM 200

int xx[MAXNUM] ;

int totNum = 0 ; /* 文件IN.DAT中共有多少个正整数 */

int totCnt = 0 ; /* 符合条件的正整数的个数 */

double totPjz = 0.0 ; /* 平均值 */

int ReadDat(void) ;

void WriteDat(void) ;

void CalValue(void)

{

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\007\n") ;

return ;

}

CalValue() ;

printf("文件IN.DAT中共有正整数=%d个\n", totNum) ;

printf("符合条件的正整数的个数=%d个\n", totCnt) ;

printf("平均值=%.2lf\n", totPjz) ;

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

if((fp = fopen("in.dat", "r")) == NULL) return 1 ;

while(!feof(fp)) {

fscanf(fp, "%d,", &xx[i++]) ;

}

fclose(fp) ;

return 0 ;

}

void WriteDat(void)

{

FILE *fp ;

fp = fopen("OUT9.DAT", "w") ;

fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

fclose(fp) ;

}

===============================================================================

所需数据 :

===============================================================================

@2 IN.DAT 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 $OUT9.DAT 003

|160\|78\|5182.50

#E第九套

===============================================================================

试题说明 :

===============================================================================

已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中。请编制函数CalValue( ), 其功能要求: 1. 求出这文件中共有多少个正整数totNum; 2. 求这些数中的百位数位置上的数字小于十位数位置上的数字的数的个数totCnt, 以及满足此条件的这些数的算术平均值totPjz, 最后调用函数WriteDat()把所求的结果输出到文件OUT9.DAT中。

注意: 部分源程序存放在PROG1.C中。

请勿改动主函数main( )、读数据函数ReadDat()和输出数据

函数WriteDat()的内容。

===============================================================================

程序 :

===============================================================================

#include

#include

#define MAXNUM 200

int xx[MAXNUM] ;

int totNum = 0 ; /* 文件IN.DAT中共有多少个正整数 */

int totCnt = 0 ; /* 符合条件的正整数的个数 */

double totPjz = 0.0 ; /* 平均值 */

int ReadDat(void) ;

void WriteDat(void) ;

void CalValue(void)

{

}

void main()

{

clrscr() ;

if(ReadDat()) {

printf("数据文件IN.DAT不能打开!\007\n") ;

return ;

}

CalValue() ;

printf("文件IN.DAT中共有正整数=%d个\n", totNum) ;

printf("符合条件的正整数的个数=%d个\n", totCnt) ;

printf("平均值=%.2lf\n", totPjz) ;

WriteDat() ;

}

int ReadDat(void)

{

FILE *fp ;

int i = 0 ;

if((fp = fopen("in.dat", "r")) == NULL) return 1 ;

while(!feof(fp)) {

fscanf(fp, "%d,", &xx[i++]) ;

}

fclose(fp) ;

return 0 ;

}

void WriteDat(void)

{

FILE *fp ;

fp = fopen("OUT9.DAT", "w") ;

fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

fclose(fp) ;

}

===============================================================================

所需数据 :

===============================================================================

@2 IN.DAT 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 $OUT9.DAT 003

|160\|78\|5182.50

#E

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值