C ++编程,删除文件中的重复电子邮件并创建没有重复项的新文件,

时间:2017-02-22 04:01:46

标签: c++ arrays sorting duplicates

我为考试成绩编写代码,想知道我是否可以使用相同的代码删除重复的电子邮件列表,我想我可以将int更改为字符串,我会没事的,但发现我错了, 请帮忙。

      //my main.cpp
     #include<iostream>
    #include<fstream>
    #include "rawlist.dat"
   using namespace std;

   string examScore[250], len;

   void ReadScore()
     {
         //Declares an object of ifstream for reading
         ifstream rfile;
        //Opens the file input.txt in read mode
       rfile.open("rawlist.dat");
        len = 0;
          //Loops till end of the file
           while(!rfile.eof())
         {
           //Reads a character
        rfile>>examScore[len++];
         }//End of while loop
        }//End of read function


 void ShowScore()
 {
         cout<<"\n Exam Score ";
     for (string x = 0; x< len; x++)
    cout<< examscore[x] << " ";
   //Loops till end of array

    cout<<endl;
    }


     void SortScore()
       {
  string Temp, x, y;
 //Loops till end of array
  for(x = 0; x < len; x++)
  {
  //Loops till end of array - current x value - 1
     for(y = 0; y < len - x - 1; y++)
   {
     swap
  if(examScore[y] < examScore[y + 1])
  {
  //Swapping
    Temp = examScore[y];
   examScore[y] = examScore[y + 1];
   examScore[y + 1] = Temp;
   }//End of if
  }//End of for loop for variable y
  }//End of for loop for variable x
 }//End of function


 void BarChart()
  {
 //Loops till end of array
 for(string x = 0; x < len; x++)
  {

  cout<<examScore[x]<<" ";

  for(string y = 0; y < examScore[x]; y++)
  cout<<"*";
  cout<<endl;
 }//End of for loop
   }
  //Main function
  int main()
  {
  ReadScore();
   SortScore();
  ShowScore();
  BarChart();
   }



 //my rwlist.h file
  hello@gmail.com
     hello@gmail.com
    usa@gamil.com
   world@gmail.com
   cplusplus@gmail.com
   light@gmail.com
   world@gmail.com
   light@gmail.com



        Please help, Thank you very very much. 

0 个答案:

没有答案