• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 22nd, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<iostream>
2.
3. using namespace std;
4.
5.
6. /*int licznik() {
7.     static int l = 0;
8.     ++l;
9.     return l;
10. }*/
11.
12.
13. int silnia(int n) {
14.
15.     if (n < 2) {
16.         return n;
17.     }
18.     return n * silnia(n - 1);
19.
20. }
21.
22. int nwd_1(int a, int b) {
23.
24.     if (a > b) {
25.         return nwd_1(a - b, b);
26.     }
27.
28.     else {
29.         return nwd_1(a, b - a);
30.     }
31.
32.     return a;
33. }
34.
35. int nwd_2(int a, int b) {
36.
37.     if (b!= 0) {
38.         return nwd_2(b, a % b);
39.     }
40.     return a;
41. }
42.
43. int main() {
44.
45.     int zadanie, a, b, n;
46.
47.     cout << "Podaj numer zadanie: " << endl << "Zadanie 1" << endl << "Zadanie 2" << endl << "Zadanie 3" << endl;
48.     cin >> zadanie;
49.
50.     if (zadanie == 1) {
51.
52.         cout << "Podaj zmienna: ";
53.         cin >> n;
54.         cout << n << "!=" << silnia(n) << endl;
55.
56.     }
57.
58.     else if (zadanie == 2) {
59.
60.         cout << "Podaj pierwsza zmienna: ";
61.         cin >> a;
62.         cout << "Podaj druga zmienna: ";
63.         cin >> b;
64.         cout << nwd_1(a, b) << endl;
65.
66.     }
67.
68.     else if (zadanie == 3) {
69.
70.         cout << "Podaj pierwsza zmienna: ";
71.         cin >> a;
72.         cout << "Podaj druga zmienna: ";
73.         cin >> b;
74.
75.         cout << nwd_2(a, b) << endl;
76.
77.     }
78.
79.     else {
80.         cout << "Nie wybrano zadania" << endl;
81.         main();
82.     }
83.
84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top