当前位置:网站首页>怎样写一个增广矩阵到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;
}
边栏推荐
- Default constraint and zero fill constraint of MySQL constraint
- NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
- Deployment, recall and deletion solutions - stsadm and PowerShell "suggestions collection"
- Wechat official account oauth2.0 authorizes login and displays user information
- Goal: do not exclude yaml syntax. Try to get started quickly
- Win11游戏模式怎么开启?Win11开启游戏模式的方法
- Programming mode - table driven programming
- Leetcode SQL first day
- Static test tool
- 使用 BlocConsumer 同时构建响应式组件和监听状态
猜你喜欢
[open source] Net ORM accessing Firebird database
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Win11时间怎么显示星期几?Win11怎么显示今天周几?
2022 how to evaluate and select low code development platforms?
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
Ad domain group policy management
Jerry's about TWS pairing mode configuration [chapter]
An in-depth understanding of fp/fn/precision/recall
ISO 26262 - considerations other than requirements based testing
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
随机推荐
使用 CustomPaint 绘制基本图形
Addition, deletion, modification and query of sqlhelper
Description of the difference between character varying and character in PostgreSQL database
Deployment, recall and deletion solutions - stsadm and PowerShell "suggestions collection"
JNI primary contact
Latest Android advanced interview questions summary, Android interview questions and answers
Jerry's about TWS channel configuration [chapter]
Jerry's about TWS pairing mode configuration [chapter]
Use br to recover backup data on azure blob storage
How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
Qt编写物联网管理平台39-报警联动
Insufficient permissions
Index summary (assault version)
Wechat official account oauth2.0 authorizes login and displays user information
Can I open a stock account directly online now? Is it safe?
How can big state-owned banks break the anti fraud dilemma?
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
OpenGL super classic learning notes (1) the first triangle "suggestions collection"
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry