Advertisement
Guest User

Untitled

a guest
May 28th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. PRVI
  2. #include <iostream>
  3. #include <cstdlib>
  4. using namespace std;
  5. int brojanje(int a){
  6.  
  7. if(a<10000){
  8. int brojac = 0;
  9. while(a){
  10. a/=10;
  11. brojac++;
  12. }
  13.  
  14. return brojac;
  15. }
  16. else return 0;
  17. }
  18. int main () {
  19. int a;
  20. cout<<"Unesite jedan cijeli broj: ";
  21. cin>>a;
  22. cout<<"Broj znamenki unesenog broja je: "<<brojanje(a)<<endl;
  23.  
  24.  
  25.  
  26.  
  27. system("PAUSE");
  28. return 0;
  29. }
  30.  
  31. DRUGI
  32. #include <iostream>
  33. #include <cstdlib>
  34. using namespace std;
  35. int parni(int x[4]){
  36. int brojac = 0;
  37. for(int i = 0; i<4;i++){
  38. if(x[i]%2==0)brojac++;
  39. }
  40. return brojac;
  41. }
  42. int main () {
  43. int a[4];
  44. cout<<"Unesite 4 cijela broja:"<<endl;
  45. for(int i = 0; i<4;i++){
  46. cin>>a[i];
  47.  
  48. }
  49. cout<<"Broj parni brojeva: "<<parni(a)<<endl;
  50.  
  51.  
  52.  
  53. system("PAUSE");
  54. return 0;
  55. }
  56.  
  57. TRECI
  58. #include <iostream>
  59. #include <cstdlib>
  60. using namespace std;
  61. int provjera(int x){
  62.  
  63. if(x<0)cout<<"Broj je negativan!"<<endl;
  64. else
  65. cout<<"broj je pozitivan!"<<endl;
  66. }
  67. int main () {
  68. int a;
  69. cout<<"Unesite jedan broj: ";
  70. cin>>a;
  71. provjera(a);
  72.  
  73.  
  74.  
  75.  
  76. system("PAUSE");
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement