Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zadanie 1
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,y,z;
- for (x=1;x<=100;x++)
- {
- cout << x << endl;
- }
- y=1;
- do
- {
- cout << y << endl;
- y++;
- }
- while (y<=100);
- z=1;
- while(z<=100)
- {
- cout << z << endl;
- z++;
- }
- return 0;
- }
- //Zadanie 2
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,i,x;
- cout << "Podaj krance przedzielu [a,b]: " << endl;
- cin >> a >> b;
- if (b<a)
- {
- x=a;
- a=b;
- b=x;
- }
- for (i=a; i<=b; i++)
- {
- if (i%3==0)
- {
- cout << "Liczba " << i << " jest podzielna przez 3" << endl;
- }
- else
- {
- cout << "Liczba " << i << " nie jest podzielna przez 3" << endl;
- }
- }
- return 0;
- }
- //Zadanie 3
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,s;
- s=1;
- cout << "Podaj liczbe, z ktorej ma byc obliczona slinia: ";
- cin >> x;
- if (x<0)
- {
- cout << "Podana liczba < 0, program zakonczy dzialanie";
- return 0;
- }
- else if (x==0)
- {
- cout << "0!=1";
- }
- else
- {
- for (int i=1;i<=x;i++)
- {
- s=s*i;
- }
- cout << s;
- }
- return 0;
- }
- //Zadanie 4
- #include <iostream>
- using namespace std;
- int main()
- {
- int x;
- for (x=10;x<100;x++)
- {
- if (x%4==0)
- {
- cout << x << endl;
- }
- }
- return 0;
- }
- //Zadanie 5
- #include <iostream>
- using namespace std;
- int main()
- {
- int k,x;
- cout << "Podaj krok: ";
- cin >> k;
- cout << "krok = " << k << " -> ";
- for (x=0;x<=200;x=x+k)
- {
- cout << " " << x;
- }
- return 0;
- }
- //Zadanie 6
- #include <iostream>
- using namespace std;
- int main()
- {
- int i,x,s;
- i=1;
- s=0;
- while (i<=10)
- {
- cout << "Podaj " << i << " liczbe: ";
- cin >> x;
- s=s+x;
- i++;
- }
- cout << "Suma: " << s;
- return 0;
- }
- //Zadanie 7
- #include <iostream>
- using namespace std;
- int main()
- {
- int r,x;
- cout << "Podaj promien kola: ";
- cin >> r;
- for (;r<=0;r++)
- {
- cout << "Podaj wlasciwa wartosc r: ";
- cin >> r;
- }
- cout << "Pole kola: " << 3.14*r*r << endl;
- cout << "Obwod kola: " << 2*3.14*r;
- return 0;
- }
- //Zadanie 8
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,y,mn,mx;
- cout << "Podaj liczby calkowite. W momencie podania 0 program zostanie zatrzymany" << endl;
- cin >> x;
- mn=x;
- while (x!=0)
- {
- cin >> x;
- if (x!=0)
- {
- y=x;
- if (y>mx)
- {
- mx=y;
- }
- else if (y<mn)
- {
- mn=y;
- }
- }
- }
- cout << "min: " << mn << ", max: " << mx;
- return 0;
- }
- //Zadanie 9
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,x,y;
- cout << "Podaj 2 liczby: " << endl;
- cin >> a >> b;
- x=a*b;
- cout << "Podaj wynik mnozenia podanych liczb: ";
- cin >> y;
- while (x!=y)
- {
- cout << "Podany wynik jest nieprawidlowy. Podaj poprawny wynik: ";
- cin >> y;
- }
- cout << "Udalo ci sie podac poprawny wynik: " << x;
- return 0;
- }
- //Zadanie 10
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,i,j;
- char x = '*';
- cout << "Podaj a i b:" << endl;
- cin >> a >> b;
- for (j=0;j<b;j++)
- {
- for (i=0;i<a;i++)
- {
- cout << x;
- }
- cout << " " << endl;
- }
- return 0;
- }
- //Zadanie 11
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b,i,j;
- char x = '*';
- b=1;
- cout << "Podaj a: " << endl;
- cin >> a;
- for (j=0;j<a;j++)
- {
- for (i=0;i<=j;i++)
- {
- cout << x;
- }
- cout << " " << endl;
- }
- return 0;
- }
- //Zadanie 12
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,y,i;
- y=0;
- i=0;
- do
- {
- cout << "Podaj liczbe: " << endl;
- cin >> x;
- y=y+x;
- i++;
- }
- while (y<=50);
- cout << "Zsumowano " << i << " liczb" << endl << "Suma: " << y;
- return 0;
- }
- //Zadanie 13
- #include <iostream>
- using namespace std;
- int main()
- {
- int x=0,i;
- for (i=1;i<=10;i++)
- {
- x+=i*i;
- }
- cout << "Ilosc cegiel w piramidzie: " << x << endl;
- return 0;
- }
- //Zadanie 14
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,s,i;
- x=2;
- s=0;
- for (i=1;i<30;i++)
- {
- x=x*2;
- s=s+x;
- }
- cout << "Syn przez 30 dni uzbieral " << s << " zl";
- return 0;
- }
- //Zadanie 15
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,y,i;
- for (i=15;i>=1;i--)
- {
- x=x+i;
- }
- y=x*2;
- cout << "ilosc cegiel: " << x << endl;
- cout << "waga cegiel: " << y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement