Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdlib.h>
- using namespace std;
- void prohod(float& a, float& b)
- {
- if (a>b)
- {
- float pom = a;
- a=b;
- b=pom;
- }
- }
- int main(int argc,char** argv)
- {
- argv[1];
- argv[2];
- /*
- const int N=50;
- int nahod[N];
- for(int i=0;i<N;i++)
- {
- nahod[i]=rand()%1000+1;
- cout<<endl;
- }
- ofstream myFile("pokus.txt");
- if (myFile.is_open())
- {
- for(int i=0;i<N;i++)
- {
- myFile<<nahod[i]<<endl;
- }
- myFile.close();
- }
- int n=0;
- int pole2[1000];
- ifstream inFile("pokus.txt");
- if(inFile.is_open())
- {
- while(inFile>>pole2[n])
- {
- n++;
- }
- for(int i=0;i<n;i++)
- {
- cout<<pole2[i]<<endl;
- }
- }
- inFile.close();
- */
- ifstream vystup(argv[1]);
- const int N=1000;
- float pole[1000];
- int n=0;
- if(vystup.is_open())
- {
- while(vystup>>pole[n])
- {
- n++;
- }
- vystup.close();
- }
- ofstream outFile(argv[2]);
- if(outFile.is_open())
- {
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- if(pole[i]<pole[j])
- {
- float pom=pole[i];
- pole[i]=pole[j];
- pole[j]=pom;
- }
- }
- }
- for(int i=0;i<n;i++)
- {
- outFile<<pole[i]<<endl;
- }
- outFile.close();
- }
- int q=7;
- //pole[] je setridene
- for(int i=0;i<n;i++)
- {
- if(pole[i]==q)
- {
- cout<<"Found!"<<endl;
- break;
- }
- }
- /*
- cout<<"ahoj"<<endl;
- cout<<argc<<endl;
- cout<<argv[0]<<endl;
- cout<<argv[1]<<endl;
- cout<<argv[2]<<endl;*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement