Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie 1.
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main ()
- {
- srand(time(NULL));
- for (int i=0; i<3; i++)
- {
- cout<<rand()%(9+1)<<endl;
- }
- }
- Zadanie 2.
- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int a=10;
- int b=20;
- int c;
- int d=0;
- srand(time(NULL));
- for (int x; x=10; x>0; x--)
- {
- c=a+rand()%(b-a+1);
- d=d+c;
- }
- return 0;
- }
- Zadanie 3.
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main ()
- {
- int a=10;
- int b=20;
- int c;
- int d=0;
- srand(time(NULL));
- for(int x=100; x>0; x--)
- {
- c=a+rand()%(b-a+1);
- d=d+c;
- }
- cout<<"suma wynosi"<<d<<endl;
- return 0;
- }
- Zadanie 4.
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a=1;
- int b=2;
- int x;
- srand(time(NULL));
- x=a+rand()%(b-a+1);
- if (x==2)
- {
- cout<<"reszka"<<endl;
- }
- else
- {
- cout<<"orzel"<<endl;
- }
- return 0;
- }
- Zadanie 5.
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int a=-1000;
- int b=1000;
- int c=0;
- srand(time(NULL));
- do
- {
- c=a+rand()%(b-a+1);
- cout<<c<<endl;
- }
- while(!(c>100&&c<200));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment