- 相關(guān)推薦
關(guān)于全國計算機等級考試筆試內容
初始化
#include
#include
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ; /* 文件IN.DAT中共有多少個(gè)正整數 */
int totCnt = 0 ; /* 符合條件的正整數的個(gè)數 */
double totPjz = 0.0 ; /* 平均值 */
int ReadDat(void) ;
void WriteDat(void) ;
void CalValue(void)
{
}
void main()
{
int i ;
clrscr() ;
for(i = 0 ; i < MAXNUM ; i++) xx[i] = 0 ;
if(ReadDat()) {
printf("數據文件IN.DAT不能打開(kāi)!07 ") ;
return ;
}
CalValue() ;
printf("文件IN.DAT中共有正整數=%d個(gè) ", totNum) ;
printf("符合條件的正整數的個(gè)數=%d個(gè) ", totCnt) ;
printf("平均值=%.2lf ", 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("OUT1.DAT", "w") ;
fprintf(fp, "%d %d %.2lf ", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
A::
B:EXEC
C:EXEC SQL
D:SQL
題面:
已知在文件IN.DAT中存有若干個(gè)(個(gè)數<200)四位數字的正整
數, 函數ReadDat( )是讀取這若干個(gè)正整數并存入數組xx中。請
編制函數CalValue( ), 其功能要求: 1. 求出這文件中共有多少
個(gè)正整數totNum; 2.求出這些數中的各位數字之和是奇數的數的
個(gè)數totCnt, 以及滿(mǎn)足此條件的這些數的算術(shù)平均值totPjz, 最
后調用函數WriteDat()把所求的結果輸出到文件OUT1.DAT中。
注意: 部分源程序存放在PROG1.C中。
請勿改動(dòng)主函數main( )、讀數據函數ReadDat()和輸出數據
函數WriteDat()的內容。
}
}
}
totPjz = (double) cnt / totCnt ;/*計算平均值*/
}
void main()
{
int i ;
clrscr() ;
for(i = 0 ; i < MAXNUM ; i++) xx[i] = 0 ;
if(ReadDat()) {
printf("數據文件IN.DAT不能打開(kāi)!07 ") ;
return ;
}
CalValue() ;
printf("文件IN.DAT中共有正整數=%d個(gè) ", totNum) ;
printf("符合條件的正整數的個(gè)數=%d個(gè) ", totCnt) ;
printf("平均值=%.2lf ", totPjz) ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
if((fp = fopen("in.dat", "r")) == NULL) return 1 ;
while(!feof(fp)) {
ffscanf(fp, "%d,", &xx
【全國計算機等級考試筆試內容】相關(guān)文章:
全國計算機等級考試四級筆試試題07-02
關(guān)于全國英語(yǔ)等級考試三級筆試分數表06-27
全國計算機等級考試一級練習試題07-02
全國計算機等級二級考試java練習07-01
全國少兒英語(yǔ)等級考試二星級筆試真題答案及解析06-28
全國計算機等級考試一級考試練習題07-01
全國計算機等級考試一級練習試題及答案07-02
建行柜員招聘的筆試的考試內容07-09