Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- __int64 FindNumber(int i) {
- __int64 Number = i;
- __int64 Prev = 0;
- __int64 Step = 1;
- __int64 Digit = i;
- do {
- Step *= 10;
- Number += Step * ((Digit * 2) % 10 + Prev);
- Prev = (Digit * 2) / 10;
- Digit = Number / Step;
- } while ((Digit != i) || (Prev != 0));
- Number -= Digit * Step;
- return Number;
- }
- void GetArray(__int64 *MyArr) {
- printf_s("This program searches for the smallest number, which, when you rearrange the last digit\n"
- "to the first one, is twice as large as the original\n");
- printf_s("This is the list of required numbers :\n");
- for (int i = 0; i < 7; i++) {
- MyArr[i] = FindNumber(i + 2);
- printf_s("%d : %I64d\n", i + 1, MyArr[i]);
- }
- }
- void ShowAnswer(__int64 *MyArray) {
- __int64 Min = MyArray[6];
- for (int i = 0; i < 7; i++)
- if (MyArray[i] < Min)
- Min = MyArray[i];
- printf_s("Minimum required number is : %I64d", Min);
- }
- int main(){
- __int64 ArrayNumber[7];
- GetArray(ArrayNumber);
- ShowAnswer(ArrayNumber);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement