#include <iostream>
using namespace std;
int main()
{
int YBorn , YNow ;
cout <<"what year where you born in?"<<endl;
cin >>YBorn;
cout <<"what year is it now?"<<endl;
cin >>YNow;
int YOld=YNow-YBorn;
cout<<"at the end of the year:"<<endl;
cout << "you're " <<YOld << " years old"<<endl;
int MOld = YOld*12;
cout<< "and "<<MOld<<" month old"<<endl;
int DOld=YNow/4-YBorn/4+YOld*365;
cout<<"and "<<DOld<<" days old"<<endl;
int HOld=DOld*24;
cout<<"and "<<HOld<<" hours old"<<endl;
int MinOld=HOld*60;
cout<<"and "<<MinOld<<" minutes old"<<endl;
int SOld=MinOld*60;
cout<<"and "<<SOld<<" seconds old"<<endl;
cout<<"and "<<SOld<<"000 miliseconds old"<<endl;
system("pause");
return 0;
}
#include <iostream>
#include<stdlib.h>
/*
В прямоугольной целочисельной матрице упорядочить элементы, которые размещены на главной диагонале по убыванию
*/
using namespace std;
int main() {
setlocale(LC_ALL,"rus");
cout << "Masiv do sortirovki "<< endl << endl;
int mas[5][5];
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
mas[i][j]=-10+rand()%90;
cout<<mas[i][j]<<" ";
}
cout << endl;
}
cout << endl << endl;
cout << "Masiv posle sortirovki "<< endl << endl;
/* сортировку тут нужно провести */
for(int i=0; i<5; i++){
for(int j=0; j<5; j++){
cout<<mas[i][j]<<" ";
}
cout << endl;
}
cout << endl << endl;
return 0;
сорри если не правильно.(
Ход решения:
Делим число на 2 и выписываем остатки
23460 = 11730·2 + 0
11730 = 5865·2 + 0
5865 = 2932·2 + 1
2932 = 1466·2 + 0
1466 = 733·2 + 0
733 = 366·2 + 1
366 = 183·2 + 0
183 = 91·2 + 1
91 = 45·2 + 1
45 = 22·2 + 1
22 = 11·2 + 0
11 = 5·2 + 1
5 = 2·2 + 1
2 = 1·2 + 0
Последний множитель перед 2 равный 1 записываем первым.
Затем записываем найденные остатки в обратном порядке.
Получаем: 101101110100100