Home > Back-end >  Have bosses don't know how the function implementation, very urgent!!!!!!
Have bosses don't know how the function implementation, very urgent!!!!!!

Time:09-18

Void string2date (string pdates, int [d])
{
Int k, by bm, bd.
While ((pdates [k] <'0' | | pdates [k] & gt; '9') & amp; & Kk++;
For (; Pdates [k]!='/' & amp; & KBy=by * 10 + pdates [k] - '0';
k++;
Bm=0;
For (; Pdates [k]!='/' & amp; & Pdates. Length (); K++)
Bm=bm * 10 + pdates [k] - '0';
If (pdates [k]=='/')
{
k++;
Bd=0;
For (; KBd=bd * 10 + pdates [k] - '0';
}
The else
Bd=1;
D [0]=by;
D [1]=bm;
D [2]=bd;
}
Very urgent, thank you for your bosses

CodePudding user response:

Is this implemented? But it seems {} is not quite right

CodePudding user response:

A string from left to right in turn determine (date) (month) (year), separated by/, decide to find the location of the 0-9, before then began, in turn, determine the, years, are divided by month, bm, and determine whether, so continue to determine, not just the default is 1
There is a problem as uninitialized variables, write the code of this guy is a novice,

CodePudding user response:

 string STR="2019/1/24"; 
Int year, month, day.
Stringstream stream;
char c;
The stream & lt; The stream & gt;> Year;
The stream & gt;> c;
The stream & gt;> The month;
The stream & gt;> c;
The stream & gt;> Day;
cout
  • Related