Advertisement
Guest User

Untitled

a guest
Nov 4th, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. #include <fstream>
  5. #include <conio.h>
  6.  
  7.  
  8. //class Kontakt
  9. //{
  10. //private:
  11. // string imeprezime, telbr, email;
  12. //
  13. //public:
  14. // Kontakt(string a, string b, string c)
  15. // {
  16. // imeprezime = a;
  17. // telbr = b;
  18. // email = c;
  19. // }
  20. // Kontakt()
  21. // {
  22. // imeprezime = "-";
  23. // telbr = "-";
  24. // email = "-";
  25. // }
  26. // friend ofstream& operator<< (ofstream&, Kontakt);
  27. //
  28. //};
  29. //ofstream& operator<< (ofstream& print, Kontakt probni)
  30. //{
  31. // print << "Ime i prezime: " << probni.imeprezime << "Broj telefona: " << probni.telbr << "E - mail adresa: " << probni.email << endl;
  32. // return print;
  33. //}
  34. //int main()
  35. //{
  36. // ofstream Datoteka;
  37. // Kontakt prvi[3] =
  38. // {
  39. // { "Ivan Drulak", "095928881", "fdsadsfdsfds@gmail.com" },
  40. // { "Ha Pe", "0929244441", "sdgfsd@gmail.com" },
  41. // { "Grga Staklic", "097100067", "aasdasda@gmail.com" },
  42. // };
  43. //
  44. // Datoteka.open("Tipka.txt", ios::out);
  45. //
  46. // for (int i = 0; i < 3; i++)
  47. // Datoteka << prvi[i] << endl;
  48. // Datoteka.close();
  49. // getch();
  50. //}
  51.  
  52. //
  53.  
  54. /*
  55. class Vektor
  56. {
  57. float i, j, k;
  58.  
  59. public:
  60.  
  61. Vektor()
  62. {
  63. i = 0; j = 0; k = 0;
  64. }
  65. Vektor(float a, float b, float c)
  66. {
  67. i = a; j = b; k = c;
  68. }
  69.  
  70. Vektor& operator =(const Vektor& ref)
  71. {
  72. i = ref.i;
  73. j = ref.j;
  74. k = ref.k;
  75. return *this;
  76. }
  77.  
  78. friend Vektor operator +(const Vektor& a, const Vektor& b)
  79. {
  80. return Vektor(a.i + b.i, a.j + b.j, a.k + b.k);
  81. }
  82.  
  83. friend bool operator ==(const Vektor& a, const Vektor& b)
  84. {
  85. return ((a.i == b.i) && (a.j == b.j) && (a.k == b.k));
  86. }
  87.  
  88. friend ostream& operator <<(ostream& out, Vektor& vektor)
  89. {
  90. out << "{" << vektor.i << "," << vektor.j << "," << vektor.k << "}" << endl;
  91.  
  92. return out;
  93. }
  94.  
  95. };
  96.  
  97. int main()
  98. {
  99. Vektor Tocka(1, 2, 3), Tocka_, Tockica(3, 2, 1);
  100.  
  101. cout <<"Operator == " << (Tocka == Tocka_) << endl;
  102. cout <<"Operator << " << Tockica << endl;
  103. cout <<"Operator + " << Tocka+Tockica << endl;
  104. Tocka_ = Tocka;
  105. cout << "Operator = " << Tocka_;
  106.  
  107. getch();
  108.  
  109. }
  110. */
  111. int indeks(int *a, int n)
  112. {
  113. int index=0, i;
  114. for (i = 0; i < n; i++)
  115. if (a[i] > a[index])
  116. return i;
  117. }
  118. int indeks(double *a, int n)
  119. {
  120. int index = 0, i;
  121. for (i = 0; i < n; i++)
  122. if (a[i] > a[index])
  123. return i;
  124. }
  125. int indeks(char *a, int n)
  126. {
  127. int i, min=a[0], index;
  128. for (i = 0; i < n; i++)
  129. if ((int)a[i] < min)
  130. index = i;
  131. return index;
  132. }
  133. int indeks(string a)
  134. {
  135. int i, min = a[0], index;
  136. for (i = 0; i < a.length(); i++)
  137. if ((int)a[i] < min)
  138. index = i;
  139. return index;
  140. }
  141. int main()
  142. {
  143. int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  144. double b[10] = { 1.1, 2.2, 3.3, 4.4, 5.5 };
  145. char c[10] = "tonci";
  146. string d = { "ucitelj ivan" };
  147.  
  148. cout << "int: " << indeks(a, 10) << endl;
  149. cout << "double: " << indeks(b, 10) << endl;
  150. cout << "char: " << indeks(c, 5 ) << endl;
  151. cout << "string: " << indeks(d) << endl;
  152.  
  153. getch();
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement