завершить вызов после выдачи экземпляр 'std::invalid_argument'
what(): stoi
Ввод:
Код: Выделить всё
5
[05:00 a.m.]: Server is started
[05:00 a.m.]: Rescan initialized
[01:13 p.m.]: Request processed
[01:10 p.m.]: Request processed
[11:40 p.m.]: Rescan completed
Output: 2
Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main() {
ifstream fin;
ofstream fout;
fin.open("input.txt");
string s;
int n, hh, mm;
fin >> n;
vectorA;
for (int i = 0; i < n+1; i++) {
string s;
getline(fin, s);
if (s != "") A.push_back(s);
}
fin.close();
int days = 1;
vectort;
for (int i = 0; i < A.size(); i++) {
hh = stoi(A[i].substr(1, 2));
mm = stoi(A[i].substr(4, 2));
string x = A[i].substr(7, 1);
int time = hh * 60 + mm;
if (time == 0) days++;
if (x == "p" && time != 720) time += 720;
t.push_back(time);
}
for (int i = 1; i < t.size(); i++) {
if (t[i] < t[i - 1]) days++;
}
fout.open("output.txt");
fout
Подробнее здесь: [url]https://stackoverflow.com/questions/79197783/any-mistake-in-programm-called-after-throwing-an-instance-of-stdinvalid-argu[/url]
Мобильная версия