字符串提取
#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int n,a,h,m,s;
cin>>n;
while(n--){
cin>>a;
cin>>str;
h=(str[0]-'0')*10+str[1]-'0';
m=(str[4]-'0')*10+str[5]-'0';
s=(str[8]-'0')*10+str[9]-'0';
cout<<h<<" "<<m<<" "<<s<<endl;
}
}
为什么输入10:30:29这个种类型的字符串,比如提取hour时是(str[0]-'0')*10+str[1]-'0'
但minute时是(str[4]-'0')*10+str[5]-'0'
为什么空两个位置