wonman

Untitled

Feb 26th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char* argv[]) // w tym polu z parametrami mam: "1 2 3 4 5 6"
  9. {
  10.  
  11.  
  12. int tab[100];
  13. string ciag;
  14.  
  15. for(int i =0; i<argc; i++)
  16. {
  17.     ciag = ciag + argv[i]+ " ";
  18.     //tab[i] = atoi(argv[i].c_str()); to jest nie poprawne ;> prawda? bo latiej by bylo
  19.    
  20. }
  21. cout<<"oto ciag: "<<ciag<<endl<<endl;
  22.  
  23. for(int i=0; i<ciag.length();i++)
  24. {
  25. /////////////////////////// przepsisuje na tablice
  26. size_t pozycja = ciag.find(" ");
  27. string nowy = ciag.substr(0,pozycja);
  28. tab[i]=atoi(nowy.c_str()); //konwersja do int
  29. ciag.erase(0,1); //usuwa te sspacje by znow bylo "2 3 4 5 6" bez "1 "
  30. }
  31.  
  32. for(int i=0;i<ciag.length(); i++)
  33. {
  34.     cout<<tab[i]<<endl; //wypisuje same zera :(((((((((((
  35. }
  36.  
  37.  
  38. for(int i=0;i<ciag.length(); i++) //wypis 1/tab[i]
  39. {
  40.     tab[i] = 1/tab[i];
  41.  //cout<<tab[i];   
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment