【资料结构】读档相关 12/18更

二维阵列的一维读入法

#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");
  }
}
利用一维的方式印出二维矩阵

其他

待补


<<:  乙级电脑软件设计技术士-Java 考照历程

>>:  Gulp 使用 includePaths 载入外部 Sass资源 DAY95

JavaScript入门 Day29_抓html物件

今天要讲的是在JavaScript里怎麽抓到html的东西,那抓到之後就可以对那物件做一些事 那其实...

Day18 Plugin 从零开始到上架 01

目标 接下来将实作一个Flutter Plugin 来上架至pub.dev,为整合Instagram...

第 04 天 坚持刷题持续进步( leetcode 098 )

https://leetcode.com/problems/validate-binary-sea...

【把玩Azure DevOps】Day18 CI/CD从这里:Pipeline设定Yaml以外的Trigger方式

前一篇提到了Build pipeline的排程除了可以在Yaml内设定之外,也可以透过传统UI的方式...

Day 15【web3.js】一袋米要扛几楼

【前言】 这两天的文章都是 web3.js 的学习笔记,大部分内容都来自他们的官方文件!之後还会有...