⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readmatrix.c

📁 在MPI上实现的矩阵相乘并行计算的源程序。
💻 C
字号:
/*read a matrix from a file*/#include "stdio.h"#include  "stdlib.h"#define CHARSIZE sizeof(char)#define INTSIZE sizeof(int)int main(){ char *filename;  FILE *fd; /*file pointee to the file */  int i,j;  int row,column;  int value;  filename=(char *)malloc(CHARSIZE*128);if (filename==NULL){printf("CANNOT allocate space for filename\n");exit(0);}  printf("Read the content of a file\n");  printf("Filename:");  scanf("%s",filename);  fd=fopen(filename,"r"); /*open a file for read only and the stream is positioned at the beginning ofthe file*/if(fd==NULL) /*error in opening the file*/  {free(filename);printf("CANNOT open the file %s coorectly\n",filename);exit(0); /*exit the system*/ }/*if*/fread(&row,INTSIZE,1,fd);fread(&column,INTSIZE,1,fd);printf("Row=%d,Column=%d\n",row,column);for (i=0;i<row;i++) { for(j=0;j<column;j++)   { fread(&value,INTSIZE,1,fd);     printf("%d ",value);   }/*for j*/ printf("\n");}/*for i*/fclose(fd);/*close file pointer*/free(filename);/*free dynamic allocated space*/return(0);  }/*main*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -