#include "stdafx.h"
#include <stdio.h>//i/o
#include <conio.h> //_getch()
#include <ctype.h> //toupper
int main()
{
long i,n;
float cost, p,buf;
do
{
printf("Vvedite pervonachalnuy stoimost : ");scanf_s("%f",&cost);
printf("Vvedite procent p % : ");scanf_s("%f",&p);
printf("Vvedite n chisl Let : ");scanf_s("%u",&n);
for(i = 0; i < n; i++)
{
printf("Let %u\r\n",i + 1);
buf = cost*p/100;
printf("Stoimost za zimmu + : %f\r\n",(cost += buf));
buf = cost*p/100;
printf("Stoimost za zimmu -: %f\r\n",(cost -= buf));
}
printf("Stoimost %u Let %f\r\n",i,cost);
printf("Najmite Y - new input\r\n");
}
while(toupper(_getch()) == 'Y');
return 0;
}
101111102
Объяснение:
110110(2) + 136(10) =
1101102 = 25*1 + 24*1 + 23*0 + 22*1 + 21*1 + 20*0 = 32 + 16 + 0 + 4 + 2 + 0 = 54
ответ: 1101102=54
54 + 136 = 190
190(2) = 101111102
190 div 2 = 95 190 mod 2 = 0
95 div 2 = 47 95 mod 2 = 1
47 div 2 = 23 47 mod 2 = 1
23 div 2 = 11 23 mod 2 = 1
11 div 2 = 5 11 mod 2 = 1
5 div 2 = 2 5 mod 2 = 1
2 div 2 = 1 2 mod 2 = 0
1 div 2 = 0 1 mod 2 = 1