請問如何從已讀入矩陣的資料中,萃取其中的幾行資料 |
尚未結案
|
yushu
一般會員 發表:1 回覆:0 積分:0 註冊:2007-12-20 發送簡訊給我 |
將資料檔讀入矩陣程式如下:
#include #include #define ASIZE 976 #define BSIZE 1000 int main(int argc, char *argv[]) { short Aarry[ASIZE]; short Barry[ASIZE][BSIZE]; int cnt, i; FILE *fptr; fptr = fopen("GASP.SetTwo.Label", "r"); if (fptr == NULL) printf("\n GASP.SetTwo.Label資料檔不存在!\n"); else { printf(" GASP.SetTwo.Label 讀檔中 ...\n"); cnt = 0; while (!feof(fptr)) { fscanf(fptr, "%hd\n", &Aarry[cnt]); cnt = cnt 1; } } printf("GASP.SetTwo.Label 共有 %d 筆資料\n", cnt); fclose(fptr); system("PAUSE"); fptr = fopen("GASP.SetTwo.1_50000", "r"); if (fptr == NULL) printf("\n GASP.SetTwo.1_50000資料檔不存在!\n"); else { printf(" GASP.SetTwo.1_50000 讀檔中 ...\n"); cnt = 0; while (!feof(fptr) && cnt < ASIZE) { for (i = 0; i < BSIZE; i ) fscanf(fptr, "%hd",&Barry[cnt][i]); cnt = cnt 1; } } printf(" GASP.SetTwo.1_50000 共有 %d 筆資料\n", cnt); fclose(fptr); system("PAUSE"); return 0; } 這是前段讀進資料程式,接著我想將讀入資料萃取其中幾行出來,我要如何寫程式呢? (1)假設讀進3,7,9這些數字,程式可以將矩陣的3,7,9行資料全部取出。 (2)並將矩陣的3,7,9行資料從新編排至新矩陣的1,2,3行中。 請各位大俠指點我如何做?感謝!
------
莊曉柔 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |