Zadatci sa slajdova

Revision:
0:ea32457dbd8b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/petlje_z5.cpp	Tue Nov 01 17:42:39 2016 +0000
@@ -0,0 +1,42 @@
+#include <iostream>
+#include <ctime>
+#include <cstdlib>
+#include <windows.h>
+
+
+using namespace std;
+
+int main (){
+
+    int a = 1;
+    int b = 100;
+    int c;
+    int i = 0;
+    int rnd;
+    srand((unsigned) time (NULL));
+
+    do {
+
+        cout << "Upisi broj izmedu 1 i 100: ";
+        cin >> c;
+    } while (c > 100 || c < 1);
+
+    do {
+        rnd = rand() % (b-a+1)+a;
+        cout << "Provjeravam broj: " << rnd<< endl;
+        Sleep(200);
+
+
+            if (rnd == c){
+                cout << "Pogodak!" << endl;
+
+            } else {
+                cout << "Promasaj!" << endl;
+
+            }
+            i++;
+
+    } while (c != rnd);
+
+    cout << "Kompu je trebalo " << i << " pokusaja!" << endl;
+}