当前位置:网站首页>C language reading data
C language reading data
2022-06-26 15:57:00 【X1996_】
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
// Here is the write data , The digital 0~9 Write to data.txt In file
FILE *fpWrite1=fopen("out1.txt","w");
FILE *fpWrite2=fopen("out2.txt","w");
FILE *fpRead2=fopen("input2.txt","r");
FILE *fpRead3=fopen("input3.txt","r");
int flag=0;
while(1){
char a[1000];
int res=fscanf(fpRead2,"%s",a);
if(res == EOF)
break;
for(int j=0;a[j]!='\0';j++){
if(a[j]!=','){
fprintf(fpWrite1,"%c",a[j]);
// printf("%c",a[j]);
flag=1;
}else{
if(flag==1){
fprintf(fpWrite1,"%c",'\n');
// printf("\n");
flag=0;
}
}
}
if(flag==1){
// printf("\n");
fprintf(fpWrite1,"%c",'\n');
flag=0;
}
}
flag=0;
while(1){
char a[1000];
int res=fscanf(fpRead3,"%s",a);
if(res == EOF)
break;
for(int j=0;a[j]!='\0';j++){
if(a[j]!=','){
fprintf(fpWrite2,"%c",a[j]);
// printf("%c",a[j]);
flag=1;
}else{
if(flag==1){
fprintf(fpWrite2,"%c",'\n');
// printf("\n");
flag=0;
}
}
}
if(flag==1){
// printf("\n");
fprintf(fpWrite2,"%c",'\n');
flag=0;
}
}
fclose(fpWrite1);
fclose(fpWrite2);
fclose(fpRead2);
fclose(fpRead3);
FILE *fpRead1=fopen("input1.txt","r");
FILE *fpRead_2=fopen("out1.txt","r");
FILE *fpRead_3=fopen("out2.txt","r");
FILE *fpWrite3=fopen("out3.txt","w");
int max=0;
while(1){
char a[100];
int res1=fscanf(fpRead1,"%s",a);
int s=0;
for(int j=0;a[j]!='\0';j++){
s=s*10+(a[j]-'0');
}
if(s>max)
max=s;
if(res1 == EOF )
break;
}
fclose(fpRead1);
printf(" The maximum number of people is :%d people \n",max);
FILE *fpRead_1=fopen("input1.txt","r");
char sfz[20]=" ";
while(1){
char a[100];
char b[1000];
char c[1000];
int res1=fscanf(fpRead_1,"%s",a);
int s=0;
for(int j=0;a[j]!='\0';j++){
s=s*10+(a[j]-'0');
}
if(res1 == EOF )
break;
for(int i=0;i<s;i++){
int res2=fscanf(fpRead_2,"%s",b);
int res3=fscanf(fpRead_3,"%s",c);
fprintf(fpWrite3,"%s",b);
fprintf(fpWrite3,"%c",',');
fprintf(fpWrite3,"%s",c);
if(i!=max-1)
fprintf(fpWrite3,"%c",',');
}
for(;s<max;s++){
fprintf(fpWrite3,"%s"," ");
fprintf(fpWrite3,"%c",',');
fprintf(fpWrite3,"%s",sfz);
if(s!=max-1)
fprintf(fpWrite3,"%c",',');
}
fprintf(fpWrite3,"%c",'\n');
}
fclose(fpWrite3);
fclose(fpRead_1);
fclose(fpRead_2);
fclose(fpRead_3);
return 0;
}
边栏推荐
- Is it safe to open an account for mobile stock registration? Is there any risk?
- H5 close the current page, including wechat browser (with source code)
- Golang temporary object pool optimization
- JS creative icon navigation menu switch background color
- nanoPi Duo2连接wifi
- HW safety response
- el-dialog拖拽,边界问题完全修正,网上版本的bug修复
- 粒子滤波 PF——在机动目标跟踪中的应用(粒子滤波VS扩展卡尔曼滤波)
- [wechat applet] event binding, do you understand?
- Transaction input data of Ethereum
猜你喜欢

TweenMax+SVG切换颜色动画场景

IntelliJ idea -- Method for formatting SQL files

# 粒子滤波 PF——三维匀速运动CV目标跟踪(粒子滤波VS扩展卡尔曼滤波)

如何配置使用新的单线激光雷达

Analyse panoramique de la chaîne industrielle en amont, en aval et en aval de la NFT « Dry goods»

Particle filter PF -- Application in maneuvering target tracking (particle filter vs extended Kalman filter)

Reflection modification final
![[CEPH] Lock Notes of cephfs](/img/9a/b68e7b07b1187794c0dbed36eea749.png)
[CEPH] Lock Notes of cephfs

SVG大写字母A动画js特效
![[wechat applet] event binding, do you understand?](/img/83/6242e972538d0423fd4155140bb521.png)
[wechat applet] event binding, do you understand?
随机推荐
效率超级加倍!pycharm十个小技巧就是这么神
/etc/profile、/etc/bashrc、~/. Bashrc differences
How to configure and use the new single line lidar
Is it safe to open an account for mobile stock registration? Is there any risk?
全面解析Discord安全问题
Binding method of multiple sub control signal slots under QT
Particle filter PF - 3D CV target tracking with uniform motion (particle filter vs extended Kalman filter)
Use of abortcontroller
有Cmake的工程交叉编译到链接时报错找不到.so动态库文件
Evaluation - TOPSIS
JS handwritten bind, apply, call
Everyone is a scientist free gas experience Mint love crash
Audio and video learning (III) -- SIP protocol
JVM笔记
粒子滤波 PF——在机动目标跟踪中的应用(粒子滤波VS扩展卡尔曼滤波)
Summary of data interface API used in word search and translation applications
AbortController的使用
[CEPH] MKDIR | mksnap process source code analysis | lock state switching example
Tweenmax+svg switch color animation scene
评价——模糊综合评价