#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX 50
int main() {
FILE *f = fopen("new.txt", "r");
if (f == NULL) {
printf("no file");
return -1;
}
基本的读入判断,利用fopen将位置存入f,并判断档案是否存在
int count=0, top = -1, arr[MAX] = {0};
while (EOF != fscanf(f, "%d", &arr[++top])) {
}
fclose(f);
持续读档,将读到的资料放入阵列中,直到没有资料传入为止
count = sqrt(top);
printf("top=%d\n", top);
printf("now=%d\n", count);
此时top为矩阵元素总数量,利用math中的sqrt函式取top的开根号,可得边长(限同边长矩阵)
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
printf("%d ", arr[i * count + j]);
}
printf("\n");
}
}
利用一维的方式印出二维矩阵
待补
>>: Gulp 使用 includePaths 载入外部 Sass资源 DAY95
今天要讲的是在JavaScript里怎麽抓到html的东西,那抓到之後就可以对那物件做一些事 那其实...
目标 接下来将实作一个Flutter Plugin 来上架至pub.dev,为整合Instagram...
https://leetcode.com/problems/validate-binary-sea...
前一篇提到了Build pipeline的排程除了可以在Yaml内设定之外,也可以透过传统UI的方式...
【前言】 这两天的文章都是 web3.js 的学习笔记,大部分内容都来自他们的官方文件!之後还会有...