All pastes #33135 Raw Edit

Someone

public cpp v1 · immutable
#33135 ·published 2005-12-09 23:19 UTC
rendered paste body
#include <iostream>#include <fstream>#include <algorithm>#include <string>#include <sstream>using namespace std;string getline(istream &input) {	string temp;	getline(input,temp);	return temp;}int main () {	int toll[24];	int cases, numrecords, i, j, bill;	string license1, license2, type1, type2;	char lictemp1[25], lictemp2[25], typetemp1[10], typetemp2[10];	int hour1=0, location1=0, location2=0;	stringstream iss;	iss.clear();	iss.str(getline(cin));	iss >> cases;	iss.clear();	iss.str(getline(cin));	for (i=0; i<cases; i++) {		if (i)			cout << endl;		string records[1000];		numrecords=0;		iss.clear();		iss.str(getline(cin));		for (j=0; j<24; j++)			iss >> toll[j];		iss.clear();		iss.str(getline(cin));		while (!iss.str().empty()) {			records[numrecords]=iss.str();			numrecords++;			iss.clear();			iss.str(getline(cin));		}		sort(records, records+numrecords);		bill=0;		for (j=0; j<numrecords-1; j++) {			sscanf(records[j].c_str(), "%s %*d:%*d:%d:%*d %s %d", lictemp1, &hour1, typetemp1, &location1);			sscanf(records[j+1].c_str(), "%s %*d:%*d:%*d:%*d %s %d", lictemp2, typetemp2, &location2);			license1=lictemp1;			license2=lictemp2;			type1=typetemp1;			type2=typetemp2;			//cout << license1 << " " << license2 << endl;			if (license1!=license2) {				if (bill) {					bill+=200;					if (bill%100<10)						cout << license1 << " $" << bill/100 << ".0" << bill%100 << endl;					else						cout << license1 << " $" << bill/100 << "." << bill%100 << endl;				}				bill=0;			}			else {				if (type1=="enter" && type2=="exit")					bill+=100+(toll[hour1]* abs(location1-location2));			}		}		if (bill) {			bill+=200;			if (bill%100<10)				cout << license1 << " $" << bill/100 << ".0" << bill%100 << endl;			else				cout << license1 << " $" << bill/100 << "." << bill%100 << endl;		}	}	return 0;}