Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- #include <fstream>
- #include <conio.h>
- //class Kontakt
- //{
- //private:
- // string imeprezime, telbr, email;
- //
- //public:
- // Kontakt(string a, string b, string c)
- // {
- // imeprezime = a;
- // telbr = b;
- // email = c;
- // }
- // Kontakt()
- // {
- // imeprezime = "-";
- // telbr = "-";
- // email = "-";
- // }
- // friend ofstream& operator<< (ofstream&, Kontakt);
- //
- //};
- //ofstream& operator<< (ofstream& print, Kontakt probni)
- //{
- // print << "Ime i prezime: " << probni.imeprezime << "Broj telefona: " << probni.telbr << "E - mail adresa: " << probni.email << endl;
- // return print;
- //}
- //int main()
- //{
- // ofstream Datoteka;
- // Kontakt prvi[3] =
- // {
- // { "Ivan Drulak", "095928881", "fdsadsfdsfds@gmail.com" },
- // { "Ha Pe", "0929244441", "sdgfsd@gmail.com" },
- // { "Grga Staklic", "097100067", "aasdasda@gmail.com" },
- // };
- //
- // Datoteka.open("Tipka.txt", ios::out);
- //
- // for (int i = 0; i < 3; i++)
- // Datoteka << prvi[i] << endl;
- // Datoteka.close();
- // getch();
- //}
- //
- /*
- class Vektor
- {
- float i, j, k;
- public:
- Vektor()
- {
- i = 0; j = 0; k = 0;
- }
- Vektor(float a, float b, float c)
- {
- i = a; j = b; k = c;
- }
- Vektor& operator =(const Vektor& ref)
- {
- i = ref.i;
- j = ref.j;
- k = ref.k;
- return *this;
- }
- friend Vektor operator +(const Vektor& a, const Vektor& b)
- {
- return Vektor(a.i + b.i, a.j + b.j, a.k + b.k);
- }
- friend bool operator ==(const Vektor& a, const Vektor& b)
- {
- return ((a.i == b.i) && (a.j == b.j) && (a.k == b.k));
- }
- friend ostream& operator <<(ostream& out, Vektor& vektor)
- {
- out << "{" << vektor.i << "," << vektor.j << "," << vektor.k << "}" << endl;
- return out;
- }
- };
- int main()
- {
- Vektor Tocka(1, 2, 3), Tocka_, Tockica(3, 2, 1);
- cout <<"Operator == " << (Tocka == Tocka_) << endl;
- cout <<"Operator << " << Tockica << endl;
- cout <<"Operator + " << Tocka+Tockica << endl;
- Tocka_ = Tocka;
- cout << "Operator = " << Tocka_;
- getch();
- }
- */
- int indeks(int *a, int n)
- {
- int index=0, i;
- for (i = 0; i < n; i++)
- if (a[i] > a[index])
- return i;
- }
- int indeks(double *a, int n)
- {
- int index = 0, i;
- for (i = 0; i < n; i++)
- if (a[i] > a[index])
- return i;
- }
- int indeks(char *a, int n)
- {
- int i, min=a[0], index;
- for (i = 0; i < n; i++)
- if ((int)a[i] < min)
- index = i;
- return index;
- }
- int indeks(string a)
- {
- int i, min = a[0], index;
- for (i = 0; i < a.length(); i++)
- if ((int)a[i] < min)
- index = i;
- return index;
- }
- int main()
- {
- int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- double b[10] = { 1.1, 2.2, 3.3, 4.4, 5.5 };
- char c[10] = "tonci";
- string d = { "ucitelj ivan" };
- cout << "int: " << indeks(a, 10) << endl;
- cout << "double: " << indeks(b, 10) << endl;
- cout << "char: " << indeks(c, 5 ) << endl;
- cout << "string: " << indeks(d) << endl;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement