ADVERTISEMENT

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Friday 29 April 2016

CSE1002:PP8:SORTING DATA IN FILE

PSUDOCODE:

START
READ s;
OPEN FILE s
SET c=0
SET vector<int> v;
while(!f.eof())
f>>c;
v.push_back(c);
end while
sort vector v
print vector v
end for
STOP

CODE:
#include<fstream>
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
ifstream f;
char s[100];
cin>>s;
char d;
f.open(s);
int c=0;
int count=0;
vector<int> v;
while(!f.eof())
{
f>>c;
v.push_back(c);
}
sort(v.begin(),v.end());
for(c=0;c<v.size();c++)
{
cout<<v[c]<<endl;
}
return 0;
}

No comments:

Post a Comment