daily pastebin goal
91%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2. // Lab 19 stuff
  3.  
  4. #include "stdafx.h"
  5.  
  6. #include <string>
  7. #include <iostream>
  8.  
  9.  
  10. using namespace std;
  11.  
  12. int parseInt(string q);
  13. void parse(string loadin, string &title, int &mns, int &scs, string &bname);
  14. int main()
  15. {
  16.     string p;
  17.     getline(cin, p);
  18.  
  19.     string t, b;
  20.     int m, s;
  21.     parse(p, t, m, s, b);
  22.  
  23.     return 0;
  24. }
  25. int parseInt(string q) {
  26.     cout << q << endl;
  27.     int val = 0;
  28.     int placeval = 1;
  29.     for (int i = 0; i < q.size(); i++) {
  30.         val += (q[q.size() - i - 1] - '0')*placeval;
  31.         placeval *= 10;
  32.     }
  33.     return val;
  34. }
  35. void parse(string loadin, string &title, int &mns, int &scs, string &bname) {
  36.     cout << loadin.find_last_of('\"') << endl;
  37.     title = loadin.substr(1, loadin.find_last_of('\"') - 1);
  38.     mns = parseInt(loadin.substr(loadin.find_last_of('\"') +2, loadin.find_first_of(':')-loadin.find_last_of('\"')-2) );
  39.  
  40.     string pt2 = loadin.substr(loadin.find_first_of(':')+1, loadin.size() - loadin.find_first_of(':'));
  41.     cout << pt2 << " " << mns << endl;
  42.     scs = parseInt(pt2.substr(0, pt2.find_first_of(' ')));
  43.     bname = pt2.substr(pt2.find_first_of(' '),pt2.size()-pt2.find_first_of(' '));
  44.     //
  45.     cout <<  title << " | " << mns << " " << scs << " | " << bname << endl;
  46.  
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top