Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <string>
- #include <fstream>
- using namespace std;
- int main(int argc, char* argv[]) // w tym polu z parametrami mam: "1 2 3 4 5 6"
- {
- int tab[100];
- string ciag;
- for(int i =0; i<argc; i++)
- {
- ciag = ciag + argv[i]+ " ";
- //tab[i] = atoi(argv[i].c_str()); to jest nie poprawne ;> prawda? bo latiej by bylo
- }
- cout<<"oto ciag: "<<ciag<<endl<<endl;
- for(int i=0; i<ciag.length();i++)
- {
- /////////////////////////// przepsisuje na tablice
- size_t pozycja = ciag.find(" ");
- string nowy = ciag.substr(0,pozycja);
- tab[i]=atoi(nowy.c_str()); //konwersja do int
- ciag.erase(0,1); //usuwa te sspacje by znow bylo "2 3 4 5 6" bez "1 "
- }
- for(int i=0;i<ciag.length(); i++)
- {
- cout<<tab[i]<<endl; //wypisuje same zera :(((((((((((
- }
- for(int i=0;i<ciag.length(); i++) //wypis 1/tab[i]
- {
- tab[i] = 1/tab[i];
- //cout<<tab[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment