妈个鸡,输出为0 的时候不能带空格!
但使用scanf("%s %d/%d/%d"…)读不到数,scanf("%s", &name)也读不到数,why?
#include <iostream>
#include <string>
using namespace std;
int main(){
int N, year, month, day, young = 0, old = 20000000, temp, cnt = 0;
string name, old_name, young_name;
cin >> N;
for(int i = 0; i < N; i++){
cin >> name;
scanf("%d/%d/%d", &year, &month, &day);
temp = year*365 + month*30 + day;
if(temp >= 1814*365 + 9*30 + 6 && temp <= 2014*365 + 9*30 + 6){
cnt++;
if(temp > young){
young = temp; young_name = name;
}
if(temp < old){
old = temp; old_name = name;
}
}
}
if(cnt) printf("%d %s %s", cnt, old_name.c_str(), young_name.c_str());
else cout << 0;
return 0;
}