-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPraktikum-Test1Zad1.cpp
48 lines (48 loc) · 1.04 KB
/
Praktikum-Test1Zad1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
//<stdio.h>, <stdlib.h> и <time.h>
using namespace std;
int countDigit(int n)
{
int count = 0;
while (n != 0)
{
n = n / 10;
++count;
}
return count;
}
void creatingNumber(int bigNumber, int array[], int smallNumber)
{
int size = 0;
int finalNumber = 0;
size = countDigit(bigNumber);
for (int i = size - 1; i >= 0; i--)
{
array[i] = bigNumber % 10;
bigNumber /= 10;
}
for (int i = 0; i < size; i++)
{
finalNumber *= 10;
if (array[i] * smallNumber > 9)
{
finalNumber += (array[i] * smallNumber) / 10;
}
else
{
finalNumber += array[i] * smallNumber;
}
}
cout << finalNumber;
}
int main()
{
int biggerNumber;
int smallerNumber;
int array[countDigit(biggerNumber)];
cout << "Enter any whole number" << endl;
cin >> biggerNumber;
cout << "Enter a number 0-9" << endl;
cin >> smallerNumber;
creatingNumber(biggerNumber, array, smallerNumber);
}