Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int broj,broj2=0,broj3=0, cifra=0, kopija, najmanji = 9, brojac = 0;
- cout << "Unesite cijeli broj N " << endl;
- cin >> broj;
- kopija = broj;
- while (broj > 0)
- {
- cifra = broj % 10;
- if (cifra < najmanji)
- {
- najmanji = cifra;
- }
- brojac++;
- broj= broj / 10;
- }
- broj = kopija;
- for (int i = 0; i < brojac; i++)
- {
- broj2 = kopija % 10;
- if (broj2 == najmanji)
- {
- broj3 += 3 * pow(10, i);
- }
- else {
- broj3 += broj2*pow(10, i);
- }
- kopija /= 10;
- }
- cout << "Broj nakon promijenjene najmanje cifre iznosi " << broj3 << endl;
- cout << "Razlika izmedu ova dva broja je " << broj - broj3 << endl;
- system("pause>0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement