Skip to content
Snippets Groups Projects
Commit fcc74200 authored by Tomáš Pachman's avatar Tomáš Pachman
Browse files

Upload New File

parent 18219261
No related branches found
No related tags found
No related merge requests found
//+kompilace jako v c ale misto gcc g++
#include <iostream>
#include <sstream>
#include <ctime>
#define LEN 20
int main(int argc, char *argv[]){
int *parr=new int[LEN];
if(parr==NULL){
std::cerr << "alokace se nepovedla" <<std::endl;
return 1;
}
int seed=time(NULL);
if(argc>1){
std::istringstream iss(argv[1]);
iss>>seed;
//if(!iss.good())
if(!iss){
std::cerr<<"chyba argumentu"<<std::endl;
std::cerr<<"pouziti:" <<argv[0]<<" [seed]"<<std::endl;
delete[] parr;
return 2;
}
}
srand(54);
for(int idx=0; idx<LEN; idx++){
parr[idx]=rand() %30;
//parr[idx]=10+rand() %20;
//parr[idx]=rand() & (32-1);
std::cout<<parr[idx]<<", ";
}
std::cout<<std::endl;
delete[] parr; //+uvolnime co jsme vzali
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment