C語言每日一練 第4題

2022-08-23 08:51:13 字數 2346 閱讀 9953

已知資料檔案in.dat中有300個四位數,並呼叫readdat()函式把這些數儲存陣列a中,編寫函式jsvalue(),其功能是:求出所有這些四位數是素數的個數cnt,再把所有滿足此條件的四位數依次存入陣列b中,然後對陣列b的按從小到大順序排列,最後編寫函式wirtedat()把陣列b中的數輸出到out.dat檔案中。

7704,9774,3213,5845,7703,2902,1925,2584,7429,6646

3793,8640,4364,3032,9190,2498,6394,3796,2434,6791

5552,9052,9159,8245,7965,1071,8157,6526,2164,6767

4853,1174,4564,5427,7279,9832,3640,7897,3211,4788

6556,4781,2168,6014,7795,6536,9461,4287,8029,8303

2609,8795,8386,3911,8130,7268,1906,7345,3678,5823

8074,6963,7874,6066,4509,8976,1740,2026,7047,4730

9538,2193,8473,6729,4207,5095,4623,4933,6226,8098

1277,5480,1906,4109,9047,1986,5882,8444,1029,6515

2612,7297,6934,8495,7731,1625,1305,7953,7385,3620

7206,4549,5736,3131,6875,6917,6087,4640,5314,8646

6077,5677,7345,4143,1513,8101,2038,9879,3946,6643

7763,6108,4788,9055,8186,5416,5699,6733,5416,2320

2430,4772,9962,9676,1319,7767,7369,1411,3663,2876

2245,4810,5400,6045,1504,4178,7264,2763,7050,1490

8790,4014,9280,7105,7113,3600,8221,8203,6127,7313

1850,5983,9689,4102,1036,6375,5064,7188,9887,9800

6871,4856,2432,9562,3426,9013,5104,4724,4785,9953

5939,6668,8700,4730,9737,4055,6544,9763,1034,2855

8078,5111,4817,4593,9876,1189,2507,1197,1782,4347

7961,8612,9699,6108,4221,2489,8895,3672,8226,8724

6302,7624,7506,8568,4013,2785,3528,6712,1155,3150

1388,5803,6328,6841,5825,7802,2022,6290,1775,3652

9699,6573,8082,9016,4369,4002,3205,2688,8414,7572

2830,1231,3888,5137,5555,8976,2543,6542,8986,5921

5346,1368,2566,3304,4089,3880,1244,6650,6523,6123

1243,7488,5262,9992,3115,9270,6989,1595,1283,2645

4075,9471,7983,9093,7642,8847,5686,4168,8550,8941

5188,2290,3219,2853,6978,9053,5843,7153,6382,6289

3022,5591,9981,7296,2421,7328,9575,7586,1190,8504

view code

#include int a[300], b[300], cnt=0

; void

readdat()

fclose(fp);

}void

writedat()

fclose(fp); }

int isp(int

m)

void

jsvalue()

}//方法一:氣泡排序

for(i=0;i)}}

//方法二:

C語言每日一練 第1題

程式的功能是 將大於整數m且緊靠m的k個素數存入陣列xx。並把in.dat檔案的內容輸入到程式,並把輸出結果輸出道out.dat資料夾中 例如 若輸入17,5 則應該輸入 19,23,29,31,37 1 in.dat檔案內容 17 5101 7321532 455676 6994781522 66...

每日一練4

員工表emp 員工編號eid,姓名ename,工作職位title,僱傭日期hiretime,工資salary,獎金bonus,部門depart 部門表dept 部門編號did,名稱dname,部門領導leader 員工資料 1001,張三 銷售 1999 12 1 3000.0,1100.0,102...

C語言每日一練7 18

a類 b類2.請編寫乙個程式,使用者輸入乙個十進位制數,將其轉換為二進位制並輸出。3.下列程式的執行結果為 include void func int x int main return 0 以下為答案 1.d 硬碟檔案系統除了fat還有ntfs u盤檔案系統 光碟檔案系統 2.include in...