anonymous No title
No License C++
2020年07月25日
Copy
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <stdlib.h>
using namespace std;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}
int main(int argc,char** argv,char** envp){
    string input = string("../data/") + argv[1] + ".csv";
    ifstream inputfs(input);
    if(!inputfs.fail()){
        string str;
        while(getline(inputfs,str)){
            cout << str << endl;
        }
        return 0;
    }
    ifstream tagfs("../data/tag.csv");
    ifstream geotagfs("../data/geotag.csv");
    string tag_line,geotag_line;
    
    if(tagfs.fail()){
        cerr << "Failed to open tag.csv" << endl;
        return -1;
    }
    if(geotagfs.fail()){
        cerr << "Failed to open geotag.csv" << endl;
    }
    cout << "file open" << endl;
    //list<string> result;
    vector<string> result;
    result.reserve(10000);
    while(getline(tagfs,tag_line)){
        //todo
        vector<string> tag_sp = split(tag_line,',');
        string tag_id = tag_sp[0];
        string tag = tag_sp[1];
        if(tag==argv[1]){
            cout << "pie" << endl;
            while (getline(geotagfs,geotag_line)){
                vector<string> geotag_sp = split(geotag_line,',');
                string geotag_id = geotag_sp[0];
                if(tag_id==geotag_id){
                    
                    string data = geotag_line.substr(11);
                    cout << data << endl;
                    result.push_back(data);//Segmentaion Fault
                    break;
                }
            }
        }
    }
    cout << "poyo" << endl;
    sort(result.begin(),result.end());
    //result.sort();
    ofstream ofs(input);
    if(ofs.fail()){
        cout << "fout.open failed" << endl;
        return -1;
    }
    for(auto itr = result.begin();itr !=result.end();++itr){
        cout << *itr << endl;
        ofs << *itr << endl;
    }
    
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <stdlib.h>
using namespace std;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}
int main(int argc,char** argv,char** envp){
    string input = string("../data/") + argv[1] + ".csv";
    ifstream inputfs(input);
    if(!inputfs.fail()){
        string str;
        while(getline(inputfs,str)){
            cout << str << endl;
        }
        return 0;
    }
    ifstream tagfs("../data/tag.csv");
    ifstream geotagfs("../data/geotag.csv");
    string tag_line,geotag_line;
    
    if(tagfs.fail()){
        cerr << "Failed to open tag.csv" << endl;
        return -1;
    }
    if(geotagfs.fail()){
        cerr << "Failed to open geotag.csv" << endl;
    }
    cout << "file open" << endl;
    //list<string> result;
    vector<string> result;
    result.reserve(10000);
    while(getline(tagfs,tag_line)){
        //todo
        vector<string> tag_sp = split(tag_line,',');
        string tag_id = tag_sp[0];
        string tag = tag_sp[1];
        if(tag==argv[1]){
            cout << "pie" << endl;
            while (getline(geotagfs,geotag_line)){
                vector<string> geotag_sp = split(geotag_line,',');
                string geotag_id = geotag_sp[0];
                if(tag_id==geotag_id){
                    
                    string data = geotag_line.substr(11);
                    cout << data << endl;
                    result.push_back(data);//Segmentaion Fault
                    break;
                }
            }
        }
    }
    cout << "poyo" << endl;
    sort(result.begin(),result.end());
    //result.sort();
    ofstream ofs(input);
    if(ofs.fail()){
        cout << "fout.open failed" << endl;
        return -1;
    }
    for(auto itr = result.begin();itr !=result.end();++itr){
        cout << *itr << endl;
        ofs << *itr << endl;
    }
    
}



年末年始は機械学習・深層学習を勉強しませんか?
No one still commented. Please first comment.
年末年始は機械学習・深層学習を勉強しませんか?
広告
未経験から最短でエンジニアへの転職を目指すなら