Целая часть от деления 39 div 8 = 4 Остаток от деления 39 mod 8 = 7 Получаем число в 8-ой системе счисления: 47 0.95*8 = 7.6 (целая часть 7) 0.6*8 = 4.8 (целая часть 4) 0.8*8 = 6.4 (целая часть 6) Получаем число в 8-ой системе счисления: 746 и так получаем 47.746 по моему так
Elshel8694
11.03.2021
// #1
#include <iostream> using namespace std;
int main() { unsigned int n; cout << "N = "; cin >> n; float a[n][n], sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << "a[" << i << "][" << j << "] = "; cin >> a[i][j]; sum += a[i][j]; } } float avg = sum / (n * n); cout << "Среднее арифметическое - " << avg << ", начинаю замену...\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (a[i][j] < 0) { cout << "a[" << i << "][" << j << "] = " << a[i][j] << " < 0, заменяю на " << avg << "...\n"; a[i][j] = avg; } } } cout << "\nИзменённый массив:\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << a[i][j]; if ( !(j == n - 1) ) cout << ' '; } if ( !(i == n - 1) ) cout << '\n'; } return 0; }
// #2
#include <iostream> using namespace std; const unsigned short int n = 7;
int main() { int a[n][n], max; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << "a[" << i << "][" << j << "] = "; cin >> a[i][j]; } } max = a[0][0]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if ( (a[i][j] > max) && (i + j > n + 1) ) max = a[i][j]; } } cout << "Максимум ниже побочной диагонали: " << max; return 0; }
tarasova
11.03.2021
1) #include <iostream> #include <math.h>
using namespace std;
int main() { int a; cin >> a; int d = a%10; string s = "yes"; while(abs(a) > 0) { if(a%10 != d) { s = "no"; break; } a/=10; } cout << s << endl; } 2) #include <iostream> #include <math.h>
using namespace std;
int main() { int a; cin >> a; int d = a%10; a/=10; string s = "no"; while(abs(a) > 0) { if(a%10 == d) { s = "yes"; break; } d = a%10; a/=10; } cout << s << endl; }
Остаток от деления 39 mod 8 = 7
Получаем число в 8-ой системе счисления: 47
0.95*8 = 7.6 (целая часть 7)
0.6*8 = 4.8 (целая часть 4)
0.8*8 = 6.4 (целая часть 6)
Получаем число в 8-ой системе счисления: 746
и так получаем 47.746
по моему так