Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include <stdio.h>
- using namespace std;
- int main(int argc, char* argv[])
- {
- string ciag;
- for(int i=1; i<argc;i++)
- {
- ciag = ciag + argv[i] + " ";
- }
- //for(int i=0; i<argc-1;i++)
- //cout<<"oto poczatek: "<<argv[i]<<endl;
- //ciag = "1 2 3 4 5 6 "; // takie powinno mi zwrocic a nie zwraca
- //cout<<ciag<<endl;
- float tab[100];
- string nowy;
- for(int i=0; i<argc;i++)
- {
- size_t pozycja = ciag.find(" ");
- nowy = ciag.substr(0,pozycja);
- tab[i] = atof(nowy.c_str());
- ciag.erase(0,2);
- }
- for(int i=0; i<argc-1;i++)
- cout<<tab[i]<<endl;
- cout<<endl;
- for(int i=0; i<argc-1;i++)
- {
- if (tab[i]==0){
- cout<<"1";
- }
- else
- {
- cout<<1/tab[i]<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment