wonman

Untitled

Feb 26th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <cmath>
  5. #include <stdio.h>
  6. #include <cstdlib>
  7. using namespace std;
  8. //Napisz program, który jako argumenty (argumenty funkcji main) otrzymuje dwa ciągi liczb całkowitych oddzielone przecinkiem. Program ma zaipsać do pliku o nazwie liczby.txt te liczby, które występują w obu ciągach.
  9. int main(int argc, char** argv)
  10. {  
  11.     string ciag, czlon1, czlon2,tmp;
  12.     int tab1[czlon1.length()];
  13.     int tab2[czlon2.length()]; 
  14.     for(int i=1; i<argc; i++)
  15.     {
  16.         ciag =ciag + argv[i] + " ";
  17.     }
  18.     size_t pozycja = ciag.find(",");
  19.     czlon1 = ciag.substr(0,pozycja);
  20.     czlon2 = ciag.substr(pozycja+2,ciag.length());
  21.    
  22.     cout<<"ciagi to: "<<endl<<czlon1<<endl<<czlon2<<"sss"<<endl<<endl;
  23.    
  24.     for(int i=0;i<czlon1.length()+3;i++)        //tab1 uzupelniamy //////////////////////////////////////////////////???????????????????????????????????????????????? i<?
  25.     {
  26.         pozycja = czlon1.find(" ");
  27.        
  28.         tmp = czlon1.substr(0,pozycja);
  29.         czlon1.erase(0,pozycja+1);
  30.         tab1[i] = atoi(tmp.c_str());   
  31.     }
  32.         for(int i=0;i<=czlon2.length()+2;i++)        //tab2 uzupelniamy /////////////////////////////???????????????????????????????????????????????? i<?
  33.     {
  34.         pozycja = czlon2.find(" ");
  35.         tmp = czlon2.substr(0,pozycja);
  36.         czlon2.erase(0,pozycja+1);
  37.         tab2[i] = atoi(tmp.c_str());       
  38.     }
  39.     for(int i = 0; i<5; i++) //////////////////////////////////////////////////////////////////////////???????????????????????????????????????????????? i<?
  40.         {
  41.         cout<<"liczby z tabelki to: "<<endl<<tab1[i]<<"  "<<tab2[i]<<endl ;
  42.         }
  43.         cout<<endl<<endl;
  44.        
  45.     for(int i=0;i<5;i++) //////////////////////////////////////////////////////////////////////////???????????????????????????????????????????????? i<?
  46.     {
  47.     for(int j=0;j<5;j++) /////////////=/////////////////////////???????????????????????????????????????????????? i<?
  48.     {
  49.             if(tab1[i]==tab2[j])
  50.             cout<<"Wyniki to: "tab1[i]<<endl;
  51.     }
  52. }  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment