c++ 读取文件字符串 并且解析
/*
"/Users/macname/Desktop/aa-1.log"
链接:https://pan.baidu.com/s/1fKB5vXDe6bYOhoslc-kr7w 密码:nb9s
*/
code:
//
// main.cpp
// demo
// #include<iostream>
#include<fstream>
#include<string>
#include <sstream>
#include<ctime>
#include<cstdlib>
#include<queue>
#include<cstdio>
using namespace std; void initialMaze();
//任意位置的结构体
struct point {
int x;
int y;
}; int main()
{
//792*675
int height=;
int width=;
//位置
int curpos[]={,};
int data[width][height];
int list[height*width]; int count=;
string a;
char x; ifstream file;
file.open("/Users/macname/Desktop/aa-1.log",ios::in);
if(!file.is_open()) return ;
string str;
string sst;
while(getline(file,str))
{
sst+=str;
}
//cout<<sst<<endl;
for(int i=;i<sst.length();i++){
x=sst[i];
if(x=='[' || x==']' || x==','){
continue;
}else{
a+=x;
if(sst[i+]==',' || sst[i+]==']'){
list[count]=stoi(a);
count+=;
a="";
}
}
} count=;
for(int i=;i<width;i++){
for(int j=;j<height;j++){
//cout<< list[count]<<endl;
if(list[count]<){
data[i][j]=;
}else if(list[count]<){
data[i][j]=;
}else{
data[i][j]=;
}
count+=;
}
} //显示
count=;
for(int i=;i<width;i++){
for(int j=;j<height;j++){
//cout<< data[i][j] <<endl;
count+=;
}
}
cout << count <<endl; return ;
}
c++ 读取文件字符串 并且解析的更多相关文章
- C 根据行来读取文件 字符串的截取
// TestCFile.cpp : Defines the entry point for the console application. // #include "stdafx.h&q ...
- 读取文件夹内容解析为Tree结构
package com.mine.io; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import ...
- Java 创建文件夹和文件,字符串写入文件,读取文件
两个函数如下: TextToFile(..)函数:将字符串写入给定文本文件: createDir(..)函数:创建一个文件夹,有判别是否存在的功能. public void TextToFile(fi ...
- IO流的练习5 —— 读取文件中的字符串,排序后写入另一文件中
需求:已知s.txt文件中有这样的一个字符串:“hcexfgijkamdnoqrzstuvwybpl” 请编写程序读取数据内容,把数据排序后写入ss.txt中. 分析: A:读取文件中的数据 B:把数 ...
- Java 读取文件到字符串
Java的io操作比较复杂 package cn.outofmemory.util; import java.io.BufferedReader; import java.io.FileInputSt ...
- 读取HTML文件进行格式化解析
#读取HTML文件进行格式化解析 $html = New-Object -ComObject "HTMLFile"; $source = Get-Content -Path &qu ...
- json数据处理:读取文件中的json字符串,转为python字典
方法1: 读取文件中的json字符串, 再用json.loads转为python字典 import json str_file = './960x540/config.json' with open( ...
- C语言:字符串读取流读取文件中的数据
#include<stdio.h> int main() { //定义文件指针 FILE *f = NULL; //打开文件 f = fopen("1.txt",&qu ...
- Java将字符串写入文件与将文件内容读取到字符串
原文:http://blog.csdn.net/liuweiyuxiang/article/details/69487326 将字符串写入文件 方法一 public void WriteStringT ...
随机推荐
- ajax实现文件上传,多文件上传,追加参数
1.html部分实现代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- 你不知道的 JSON.stringify() 的威力
掘进:https://juejin.im/post/5decf09de51d45584d238319?utm_source=gold_browser_extension#heading-19 gith ...
- springboot下@webfilter的使用
启动类加了@ServletComponentScan,无论过滤器类加不加@Componment urlPatterns = {"/test/*"}都可以生效 单使用@Compone ...
- CVE-2019-11517 CSRF in Wampserver 3.1.4-3.1.8
https://www.cnblogs.com/iAmSoScArEd/ Affected product:WampServer 3.1.4-3.1.8 Offiical description:&q ...
- 微信小程序开发demo
自己写的小程序,欢迎下载 https://gitee.com/lijunchengit/chengZiShengHuoBang
- Nginx 安装目录 和 编译参数
安装目录详解 查看安装nginx之后总共生成了哪些文件 rpm -ql nginx 在上面的文件中包括配置文件和日志文件 /etc/logrotate.d/nginx 类型:配置文件 作用:Nginx ...
- SQL SERVER-Extendevent
事件类介绍 https://docs.microsoft.com/zh-cn/previous-versions/sql/sql-server-2008/ms188275(v=sql.100)
- c# 类嵌套
- k8s的api
一.namespaced resources 所谓的namespaced resources,就是这个resource是从属于某个namespace的, 比如pod, deployment, serv ...
- 【转】SENDING KEY VALUE MESSAGES WITH THE KAFKA CONSOLE PRODUCER
SENDING KEY VALUE MESSAGES WITH THE KAFKA CONSOLE PRODUCER When working with Kafka you might find yo ...