Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctype.h>
  3. #include <string>
  4. using namespace std;
  5.  
  6. //----------------------------------------------------------------------------
  7. void zadanie1()
  8. {
  9. int liczba;
  10. int dzielnik;
  11. cout<<"Podaj liczbe";
  12. cin>>liczba;
  13. cout<<"Podaj dzielnik";
  14. cin>>dzielnik;
  15.  
  16. if (liczba%dzielnik==0)
  17. cout<<"1";
  18. else
  19. cout<<"0";
  20. }
  21. //----------------------------------------------------------------------------
  22.  
  23.  
  24. void zadanie2(int tab[100], int wartosc)
  25. {
  26. int test=0;
  27. for (int i=0; i<=99; i++)
  28. {
  29. if (tab[i]==wartosc)
  30. test++;
  31. }
  32. if (test>0)
  33. cout<<"1";
  34. else
  35. cout<<"0";
  36.  
  37. }
  38. //----------------------------------------------------------------------------
  39.  
  40.  
  41. void zadanie3()
  42. {
  43. char tekst[] = "Ala ma kota, a kot ma Ale";
  44. int dlugosc=sizeof(tekst)/sizeof(char);
  45.  
  46. for(int i=0; i<=dlugosc-1; i++)
  47. {
  48. tekst[i]=toupper(tekst[i]);
  49.  
  50. }
  51. cout<<tekst;
  52. }
  53. //----------------------------------------------------------------------------
  54.  
  55. int main() {
  56. while(true)
  57. {
  58.  
  59. cout<<"Wybierz zadanie:"<<endl;
  60. cout<<"1. Zadanie 1"<<endl;
  61. cout<<"2. Zadanie 2"<<endl;
  62. cout<<"3. Zadanie 3"<<endl;
  63.  
  64. char wybor;
  65. cin>>wybor;
  66. int tab[100]={1,2,3,4,5,6};
  67. if (wybor=='q' || wybor=='Q')
  68. exit(0);
  69. else
  70. {
  71. switch(wybor)
  72. {
  73. case '1': zadanie1(); break;
  74. case '2': zadanie2(tab, 7); break;
  75. case '3': zadanie3(); break;
  76. }
  77. }
  78.  
  79. cout<<endl;
  80.  
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement