Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- FILE* in = fopen("3.txt", "r");
- int no_of_rows = 0;
- int no_of_cols = 0;
- int nz = 0;
- fscanf(in, "%d %d %d", &no_of_rows, &no_of_cols, &nz);
- printf("no of rows: %dn", no_of_rows);
- printf("no of cols: %dn", no_of_cols);
- printf("nz values: %dn", nz);
- int* i_idx = (int*)malloc(nz * sizeof(int));
- int* j_idx = (int*)malloc(nz * sizeof(int));
- double* a = (double*)malloc(nz * sizeof(double));
- int i = 0;
- for (i = 0; i < nz; i++)
- {
- fscanf(in, "%d %d %lgn", &i_idx[i], &j_idx[i], &a[i]);
- i_idx[i]--; /* adjust from 1-based to 0-based */
- j_idx[i]--;
- }
- //double =
- for (i = 0; i < nz; i++)
- printf("%d %d %20.19gn", i_idx[i], j_idx[i], a[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement