当前位置:网站首页>怎样写一个增广矩阵到txt文件中
怎样写一个增广矩阵到txt文件中
2022-07-07 21:37:00 【51CTO】
写一个398行,399列的矩阵
#include<iostream>
using namespace std;
int main()
{
float arr1[450];
float c=1.0;
float b=2.0;
int i=0,j=0;
FILE *fp;
for(i=0;i<400;i++)
{
arr1[i]=i;
}
fp=fopen("aaa.txt","w");
for(i=0;i<399;i++)
{
for(j=0;j<=399;j++)
{
if(j==i)
fprintf(fp,"%f%c",b,' ');
else if(j==i+1 && i!=398)
fprintf(fp,"%f%c",c,' ');
else if(j==i-1)
fprintf(fp,"%f%c",c,' ');
else if(j==399)
{
fprintf(fp,"%f%c",arr1[i],' ');
}
else
fprintf(fp,"%f%c",0.0,' ');
}
}
fclose(fp);
cout<<arr1[9]<<endl;
return 0;
}
边栏推荐
- Which financial products will yield high returns in 2022?
- 2022 how to evaluate and select low code development platforms?
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
- 大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
- TCP/IP 协议栈
- 强化学习-学习笔记9 | Multi-Step-TD-Target
- ByteDance Android interview, summary of knowledge points + analysis of interview questions
- DNS series (I): why does the updated DNS record not take effect?
- Can I open a stock account directly online now? Is it safe?
- 解决uni-app中uni.request发送POST请求没有反应。
猜你喜欢

Automatic classification of defective photovoltaic module cells in electronic images

Matplotlib drawing interface settings

解决uni-app中uni.request发送POST请求没有反应。

Use json Stringify() to realize deep copy, be careful, there may be a huge hole

Ten thousand word summary data storage, three knowledge points

The little money made by the program ape is a P!

Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?

Embedded development: how to choose the right RTOS for the project?

NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
![Jerry's about TWS channel configuration [chapter]](/img/94/fde5054fc412b786cd9864215e912c.png)
Jerry's about TWS channel configuration [chapter]
随机推荐
Reinforcement learning - learning notes 9 | multi step TD target
Leetcode SQL first day
Tcp/ip protocol stack
SQL injection error report injection function graphic explanation
Datatable data conversion to entity
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
【JDBC Part 1】概述、获取连接、CRUD
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
Solve the problem of using uni app mediaerror mediaerror errorcode -5
[open source] Net ORM accessing Firebird database
The strongest installation of the twin tower model, Google is playing "antique" again?
Programming mode - table driven programming
Time standard library
Tsconfig of typescript TS basics JSON configuration options
How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
Index summary (assault version)
[开源] .Net ORM 访问 Firebird 数据库
强化学习-学习笔记9 | Multi-Step-TD-Target
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve