Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <math.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- cout << "ZADANIE 1A" << endl << endl;
- int x, y = 0;
- cout << "Podaj 2 liczby calkowite: ";
- cin >> a >> b;
- switch(a)
- {
- case 12:
- cout << "Podano liczbe 12, a druga liczba to: " << b;
- break;
- case -12:
- cout << "Kwadrat drugiej liczby: " << y * y;
- break;
- case 15:
- cout << "Druga liczba podzielona przez 5: " << (float)y / 5.0;
- break;
- case 22:
- {
- error:
- if(y < 0)
- {
- cout << "Podaj ponownie 2 liczbe (taka aby byla >= 0): ";
- cin >> y;
- goto error;
- }
- cout << "Pierwiastek z drugiej liczby: " << sqrt(y);
- break;
- }
- case -24:
- cout << "Srednia z obu liczb: " << (float)(x + y) / 2.0;
- break;
- default:
- cout << "nieprawidlowy wybor";
- }
- cout << endl;
- cout << endl << "ZADANIE 1B" << endl << endl;
- for(int i = 10; i <= 21; i++)
- {
- cout.width( 4 );
- cout << i;
- }
- cout << endl << endl;
- for(int i = 45; i >= -15; i-=5)
- {
- cout.width( 4 );
- cout << i;
- }
- cout << endl << endl;
- for(int i = 1; i <= 9; i++)
- {
- for(int a = 1; a <= 11; a++)
- {
- cout.width( 4 );
- cout << a * i;
- }
- cout << endl;
- }
- cout << endl << endl;
- for(int i = 9; i >= 2; i--)
- {
- for(int a = 7; a >= 2; a--)
- {
- cout.width( 4 );
- cout << a * i;
- }
- cout << endl;
- }
- cout << endl << "ZADANIE 2A" << endl << endl;
- cout << "Podaj liczbe A (double): ";
- cin >> A;
- jeden:
- if(A > 0)
- {
- A /= 10;
- if(A < 8)
- {
- A += 12;
- trzy:
- if(A < 50)
- {
- cout << "Liczba A: " << A << endl;
- goto koniec;
- }
- else
- {
- goto jeden;
- }
- }
- else
- {
- A -= 20;
- goto jeden;
- }
- }
- else
- {
- dwa:
- A += 10;
- if(A < 20)
- {
- goto dwa;
- }
- else
- {
- A /= 3;
- goto trzy;
- }
- }
- koniec:
- cout << endl << "ZADANIE 2B" << endl << endl;
- srand(time(NULL));
- for(int t = 0; t < 10; t++)
- {
- cout << rand() % 10 + 1 << " ";
- }
- cout << endl << endl;
- for(int t = 0; t < 10; t++)
- {
- cout << rand() % 501 - 200 << " ";
- }
- cout << endl << endl;
- for(int t = 0; t < 10; t++)
- {
- comeback:
- int a = rand() % 101 - 60;
- if (a % 4 == 0)
- cout << a << " ";
- else
- goto comeback;
- }
- cout << endl << endl;
- for(int t = 0; t < 10; t++)
- {
- float f = (rand() % 301) / 10.0;
- f -= 15.0;
- cout << f << " ";
- }
- cout << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement