Home > Back-end >  In 2020 in anhui province "H inquired why memory read crossing the line?
In 2020 in anhui province "H inquired why memory read crossing the line?

Time:12-29

 # include 
#include
#include
#include
#include
#include
using namespace std;
//string segmentation function
Vector The split (STD: : string STR, STD: : string pattern)
{
STD: : string: : size_type pos;
STD: : vector The result;
STR +=pattern;//extension string for easy operation
Int size=STR. The size ();
for(int i=0; i{
Pos=STR. Find (the pattern, I);
If (pos{
STD: : string s=STR. Substr (I, pos - I);
Result. The push_back (s);
I=pos + pattern. The size () - 1;
}
}
return result;
}
Int main () {
Int maxlen=30;
Int T;
String A, [maxlen].
for(int i=0; iGetline (cin, A [I]);
If (A [I] the at (0)=='#') {
break;
}
}
Cin> T;
for(int i=1; iIf (A [I] the at (0)=='#') {
break;
}
Char c1=':';
Strings str1;
Stringstream stream1;
Stream1 & lt; & lt; C1.
Str1=stream1. STR ();
The vector & lt; string> Result=split (A [I], str1);
/* int HH1=atoi (result [0]).
Int MM1=the result of [1].
Int was=result [3]. */




Int HH1, MM1, SS1, TT1, HH2, was, SS2, TT2=0;
Int HH1_ MM1_, SS1_ TT1_, HH2_, MM2_, SS2_, TT2_;
for(int i=0; iHH1=HH1 * 10 + result [0] [I] - '0';
}
for(int i=0; iMM1=MM1 * 10 + result [1] - [I] '0'.
}
for(int i=0; iWas=10 + result was * [3] [I] - '0';
}
Char c2='-';
String str2;
Stringstream stream2;
Stream2 & lt; & lt; C2.
Str2=stream2. STR ();
The vector & lt; string> Result_=split (result [2], str2);
Char c3=', ';
String str3;
Stringstream stream3.
Stream3 & lt; & lt; C3.
Str3=stream3. STR ();
The vector & lt; string> Result__=split (result_ [0], str3);
for(int i=0; iSS1=SS1 * 10 + result__ [0] [I] - '0';
}
for(int i=0; iTT1=TT1 result__ * 10 + [1] - [I] '0'.
}
Char c4='& gt; ';
String str4;
Stringstream stream4;
Stream4 & lt; & lt; C4.
Str4=stream4. STR ();
The vector & lt; string> Result2=split (result_ [1], the str4);
for(int i=0; iHH2=HH2 * 10 + result2 [0] [I] - '0';
}
The vector & lt; string> Result1=split (result [4], str3);
for(int i=0; iSS2=SS2 * 10 + result1 [0] [I] - '0';
}
for(int i=0; iTT2=TT2 result1 * 10 + [1] [I] - '0';
}
Int m=TT1 + T;
If (m> 1000) {
TT1_=m - 1000;
Int m1=SS1 + m/1000.
If (m1 & gt; 60) {
SS1_=m1-60;
Int + m1/m2=MM1 60;
If (m2 & gt; 60) {
MM1_=m2-60;
HH1_=HH1 + m2/60;
}
}
}
Else if (m<{
=1000)TT1_=m;
SS1_=SS1;
MM1_=MM1;
HH1_=HH1;
}
Int n=TT2 + T;
If (n> 1000) {
TT2_=n - 1000;
Int n1=SS2 + n/1000;
If (n1 & gt; 60) {
SS2_=n1-60;
Int + n1 n2=was/60;
If (n2 & gt; 60) {
MM2_=n2-60;
HH2_=HH2 + n2/60;
}
}
}
Else if (n<{
=1000)TT2_=n;
SS2_=SS2;
MM2_=was;
HH2_=HH2;
}
A [I]='HH1_ : MM1_ : SS1_, TT1_ - & gt; HH2_ : MM2_ : SS2_ TT2_ ';
}
for(int i=0; iCout<& lt; A [I] <& lt; Endl;
If (A [I] the at (0)=='#') {
break;
}
}
return 0;
}
  • Related