wonman

Untitled

Feb 26th, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <stdio.h>
  5. using namespace std;
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9.  
  10. string ciag;
  11.  
  12.  
  13. for(int i=1; i<argc;i++)
  14. {
  15.     ciag = ciag + argv[i] + " ";   
  16.  
  17. }
  18. //for(int i=0; i<argc-1;i++)
  19. //cout<<"oto poczatek: "<<argv[i]<<endl;
  20.  
  21. //ciag = "1 2 3 4 5 6 "; // takie powinno mi zwrocic a nie zwraca
  22. //cout<<ciag<<endl;
  23.  
  24. float tab[100];
  25. string nowy;
  26. for(int i=0; i<argc;i++)
  27. {
  28.     size_t pozycja = ciag.find(" ");
  29.     nowy = ciag.substr(0,pozycja);
  30.     tab[i] = atof(nowy.c_str());
  31.     ciag.erase(0,2);
  32. }
  33.  
  34. for(int i=0; i<argc-1;i++)
  35. cout<<tab[i]<<endl;
  36.  
  37. cout<<endl;
  38.  
  39. for(int i=0; i<argc-1;i++)
  40. {
  41.     if (tab[i]==0){
  42.    
  43.     cout<<"1";
  44. }
  45. else
  46. {
  47.     cout<<1/tab[i]<<endl;
  48. }
  49.    
  50. }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment