Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
petlje_z6.cpp
00001 #include <iostream> 00002 #include <ctime> 00003 #include <cstdlib> 00004 #include <windows.h> // potrebno za sleep 00005 00006 00007 using namespace std; 00008 00009 int main (){ 00010 00011 int a = 1; 00012 int b = 100; 00013 int c; 00014 int i = 0; 00015 int rnd; 00016 srand((unsigned) time (NULL)); 00017 00018 do { 00019 00020 cout << "Upisi broj izmedu 1 i 100: "; 00021 cin >> c; 00022 } while (c > 100 || c < 1); 00023 00024 do { 00025 rnd = rand() % (b-a+1)+a; 00026 cout << "Provjeravam broj: " << rnd<< endl; 00027 Sleep(200); //u milisekundama 00028 00029 00030 if (rnd == c){ 00031 cout << "Pogodak!" << endl; 00032 00033 } else { 00034 cout << "Promasaj!" << endl; 00035 00036 } 00037 i++; 00038 00039 } while (c != rnd); 00040 00041 cout << "Kompu je trebalo " << i << " pokusaja!" << endl; 00042 }
Generated on Thu Jul 14 2022 21:05:48 by
1.7.2