C++求助帮忙修改程序··········
// qimo1.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include"fstream"
#include"string"
#include
#include"iostream"
#include"vector"
#include"stdio.h"
using namespace std;
#include
//vector<> ciping(string string2);
struct Test
{
int num;
string string3;
};
static int cmp(Test w1,Test w2);
void main(int argc, char* argv[])
{
int i=1;
int pd=1;
string string1;
Test m_test;
vector::iterator iter;
vector m_vector;
vector m_vector1;
ifstream icin("D:\\7.txt",ios::in);
ofstream outfile("D:\\1.txt",ios::out);
while(icin)
{
pd=1;
icin>>string1;
/* if(i==1)
{
m_test.string3=string1;
m_test.num=1;
m_vector.push_back(m_test);
i++;
}*/
// else
//{
for(iter=m_vector.begin();iter!=m_vector.end();iter++)
{
//pd=1;
m_test=*iter;
if(m_test.string3==string1)
{
//m_test.string3=string1;
m_test.num++;
m_test.string3=string1;
m_vector.erase(iter);
// *iter=m_test;
m_vector.push_back(m_test);
pd=2;
break;
}
}
if(pd==1)
{
m_test.string3=string1;
m_test.num=1;
m_vector.push_back(m_test);
}
// }
//m_vector1=ciping(string1);
}
stable_sort(m_vector.begin(),m_vector.end(),cmp);
for(iter=m_vector.begin();iter!=m_vector.end();iter++)
{
m_test=*iter;
cout<::iterator iter;
// vector m_vector;
/// m_test.string3=string2;
// m_test.num=1;
// m_vector.push_back(m_test);
// return(m_vector);
亲帮帮忙啊,明天交,换种做法