//将下面的abc.txt中的25出现的次数:
aaa. 25 2000
bbb. 20 2001
ccc. 15 2002
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{
ifstream infile("D:\\abc.txt");
if(!infile)
{
cout<<"abc.txt can't open.\n";
return 0;
}
string line,find = "25";
int count = 0;//统计25号的天数
while(getline(infile,line)) //1请大家给解释一下
{
istringstream stream(line); //2请大家给解释一下
string month,day,year;
stream>>month;
stream>>day;
stream>>year;
const char * p = year.c_str();
int i = year.size();
if(day == find)
{
count++;
if(p[i-1] == '*')//如果有*标住的话,再加一天
count++;
}
}
infile.close();
cout<<count<<endl;
return 0;
}