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 ...
随机推荐
- java 线程并发(生产者、消费者模式)
线程并发协作(生产者/消费者模式) 多线程环境下,我们经常需要多个线程的并发和协作.这个时候,就需要了解一个重要的多线程并发协作模型“生产者/消费者模式”. Ø 什么是生产者? 生产者指的是负责生产数 ...
- 正确使用SQLCipher来加密Android数据库
Android本身自带有不加密的数据库SQLite,如果要保存密码之类的敏感数据在本地的话方法一是使用字段加密解密算法,方法二是整个数据库都加密掉.如果只是加密解密某个字段(如password)就推荐 ...
- 浅谈(IOC)依赖注入与控制反转(DI)
前言:参考了百度文献和https://www.cnblogs.com/liuqifeng/p/11077592.html以及http://www.cnblogs.com/leoo2sk/archive ...
- eigenface算法笔记
昨天看了PCA(PCA算法介绍见上一篇),今天继续看eigenface,在这里把eigenface的过程梳理下: EigenFace本质上讲,是把人脸从像素空间变换到另一个空间,在另一个空间中做相似性 ...
- ArduPilot简介
源码地址:https://github.com/ArduPilot/ardupilot/ 参考:http://ardupilot.org/dev/docs/learning-the-ardupilot ...
- phpstom激活
phpstom官网:https://www.jetbrains.com/phpstorm/download 激活方法:激活时选择License server 填入http://idea.imsxm.c ...
- springboot 打包发布(war包)
版本关系: 软件名称 版本号 软件名称 版本号 spring boot 2.x jdk 1.8 tomcat 9.x springboot中的pom.xml文件 打包:右键点击项目,选择如下图: 填写 ...
- ES Client
关于 ElasticSearch的学习参见:ELK | wjcx_sqh 本文分别学习 .Net | Java 下操作 ES: .Net 目前主流的 .Net 客户端有 2 种: PlainElast ...
- Linux之python3编译安装
一,前言 centos7默认是装有python的,咱们先看一下 [root@glh ~ 20:18:03]#python Python 2.7.5 (default, Jul 13 2018, 13: ...
- imx6q 启动logo
转:https://wenku.baidu.com/view/81fa0f3982c4bb4cf7ec4afe04a1b0717fd5b30e.html?rec_flag=default&sx ...