limun11

Untitled

Aug 31st, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. char unos(char niz[], int a)
  7. {
  8. for (int i = 0; i<a; i++)
  9.  
  10. for (;;)
  11. {
  12. cin >> niz[i];
  13. if
  14. ((niz[i]<'A' && niz[i]<'Z') && (niz[i]<'a' && niz[i]<'z'))
  15. break;
  16. else
  17. cout << "Pogresan unos!" << endl;
  18. }
  19. return 0;
  20. }
  21.  
  22. void promijeni(char niz[], int niz2[], int a)
  23. {
  24. for (int i = 0; i<a; i++)
  25. {
  26. niz2[i] = niz[i];
  27. cout << niz2[i] << endl;
  28. }
  29. cout << endl;
  30. }
  31.  
  32. bool pretraga(int niz[], int a, int b, int&c)
  33. {
  34. if (niz[a] == b)
  35. {
  36. c++;
  37. return true;;
  38. }
  39. return false;
  40.  
  41. }
  42. int main()
  43. {
  44. char niz[5];
  45. int niz1[5];
  46. int b = 5;
  47. int c = 0;
  48. int d = 0;
  49. unos(niz, b);
  50. promijeni(niz, niz1, b);
  51. c = rand() % 100 + 8;
  52. for (int i = 0; i<b; i++)
  53. {
  54. pretraga(niz1, i, c, d);
  55. }
  56. cout << d;
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment