Advertisement
Guest User

cv9

a guest
Nov 27th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. void prohod(float& a, float& b)
  7. {
  8.     if (a>b)
  9.     {
  10.         float pom = a;
  11.         a=b;
  12.         b=pom;
  13.     }
  14. }
  15. int main(int argc,char** argv)
  16. {
  17.     argv[1];
  18.     argv[2];
  19.     /*
  20.     const int N=50;
  21.     int nahod[N];
  22.     for(int i=0;i<N;i++)
  23.     {
  24.         nahod[i]=rand()%1000+1;
  25.         cout<<endl;
  26.     }
  27.  
  28.     ofstream myFile("pokus.txt");
  29.  
  30.     if (myFile.is_open())
  31.     {
  32.    
  33.     for(int i=0;i<N;i++)
  34.     {
  35.         myFile<<nahod[i]<<endl;
  36.     }
  37.  
  38.     myFile.close();
  39.     }
  40.  
  41.     int n=0;
  42.     int pole2[1000];
  43.  
  44.     ifstream inFile("pokus.txt");
  45.  
  46.     if(inFile.is_open())
  47.     {
  48.         while(inFile>>pole2[n])
  49.         {
  50.             n++;
  51.         }
  52.         for(int i=0;i<n;i++)
  53.         {
  54.             cout<<pole2[i]<<endl;
  55.         }
  56.     }
  57.  
  58.  
  59.     inFile.close();
  60.     */
  61.  
  62.    
  63.  
  64.     ifstream vystup(argv[1]);
  65.  
  66.         const int N=1000;
  67.     float pole[1000];
  68.     int n=0;
  69.  
  70.  
  71.     if(vystup.is_open())
  72.     {
  73.         while(vystup>>pole[n])
  74.         {
  75.             n++;
  76.         }
  77.         vystup.close();
  78.     }
  79.  
  80.    
  81.  
  82.     ofstream outFile(argv[2]);
  83.  
  84.     if(outFile.is_open())
  85.     {
  86.         for(int i=0;i<n;i++)
  87.         {
  88.             for(int j=0;j<n;j++)
  89.             {
  90.                 if(pole[i]<pole[j])
  91.                 {
  92.                     float pom=pole[i];
  93.                     pole[i]=pole[j];
  94.                     pole[j]=pom;
  95.                 }
  96.             }
  97.         }
  98.         for(int i=0;i<n;i++)
  99.         {
  100.             outFile<<pole[i]<<endl;
  101.         }
  102.         outFile.close();
  103.     }
  104.  
  105.     int q=7;
  106.  
  107.     //pole[] je setridene
  108.     for(int i=0;i<n;i++)
  109.     {
  110.         if(pole[i]==q)
  111.         {
  112.             cout<<"Found!"<<endl;
  113.             break;
  114.         }
  115.  
  116.     }
  117.  
  118.    
  119.  
  120.  
  121.     /*
  122.     cout<<"ahoj"<<endl;
  123.     cout<<argc<<endl;
  124.     cout<<argv[0]<<endl;
  125.     cout<<argv[1]<<endl;
  126.     cout<<argv[2]<<endl;*/
  127.     return 0;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement