Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- NOTE: This code segmentation faults. I'm not responsible if it causes
- your computer to explode. Kthxbai.
- */
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <cstdlib>
- #include <vector>
- #include <sstream>
- using namespace std;
- typedef struct{
- string name;
- int ram;
- int cpu;
- int hdd;
- }computer;
- int main(int argc, char *argv[]){
- int numComps;
- int ram;
- int cpu;
- int hdd;
- vector<computer> computers;
- cin >> numComps;
- for(int i = 0; i < numComps; ++i){
- string inData;
- string tempString;
- vector<string> dataVector;
- computer tempComp;
- stringstream ss;
- getline(cin, inData);
- for(int ii = 0; i < inData.size(); ++i){
- if(inData[ii] == ' '){
- ss >> tempString;
- continue;
- }
- else{
- ss << inData[ii];
- }
- }
- tempComp.name = dataVector[0];
- tempComp.ram = atoi(dataVector[1].c_str());
- tempComp.cpu = atoi(dataVector[2].c_str());
- tempComp.hdd = atoi(dataVector[3].c_str());
- computers.push_back(tempComp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement