Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2014 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/185a678eefed239be53a to your computer and use it in GitHub Desktop.
Save anonymous/185a678eefed239be53a to your computer and use it in GitHub Desktop.
int main()
{
ifstream in1("in1.txt");
vector<int> mas;
int r=0; int m=0;
while(!in1.eof())
{
in1>>m;
mas.push_back(m);
r++;
}
in1.close();
int x;
bool var;
cout<<"Please, type number. 0- Sorting ascending, 1- Sorting in decreasing order. \n";
cin>>var;
if (var==0) {sort(mas.begin(), mas.end());}
else if (var==1) {sort(mas.end(), mas.begin());}
ofstream out1("out1.txt");
for (vector<int>::iterator it=mas.begin(); it!=mas.end(); it++)cout<<" "<<*it;
return 0;
}
@AlexTalker
Copy link

line 5, unuser variable r.

@AlexTalker
Copy link

Oh, use in line 10, but don't anything good.

@AlexTalker
Copy link

Container vector have method size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment