1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
const int MAX = 50;
void convertCase(string& name, ofstream& out);
int convertHours(int hh);
int convertMinutes(int mm);
int main()
{
string filename, filenameout;
string fname;
string start;
string end;
ifstream in;
ofstream out;
int totalSec[MAX];
int hh, hh2, mm, mm2, ss, ss2, seconds, seconds2;
int i = 0;
cout << "Enter name of input file" << endl;
cin >> filename;
in.open("input.txt");
cout << "Enter name of output file" << endl;
cin >> filenameout;
out.open("output.txt");
in >> fname;
while (in)
{
convertCase(fname, out);
in >> hh;
in.ignore(100, ':');
in >> mm;
in.ignore(100, ':');
in >> ss;
in >> hh2;
in.ignore(100, ':');
in >> mm2;
in.ignore(100, ':');
in >> ss2;
seconds = convertHours(hh) + convertMinutes(mm) + ss;
seconds2 = convertHours(hh2) + convertMinutes(mm2) + ss2;
totalSec[i+0] = seconds2 - seconds;
out << setw(2) << setfill('0') << hh << ":"
<< setw(2) << setfill('0') << mm << ":" << setw(2) << setfill('0') << ss << " ";
out << setw(2) << setfill('0') << hh2 << ":"
<< setw(2) << setfill('0') << mm2 << ":" << setw(2) << setfill('0') << ss2 << " ";
out << setfill(' ');
out << totalSec[i + 0] << endl;
in >> fname;
i++;
}
in.close();
out.close();
return 0;
}
void convertCase(string& name, ofstream& out)
{
name[0] = toupper(name[0]);
for (int i = 1; i < name.length(); i++)
{
name[i] = tolower(name[i]);
}
out << left << setw(15) << name << " ";
}
int convertHours(int hh)
{
return hh * 3600;
}
int convertMinutes(int mm)
{
return mm * 60;
}
|