1)uses crt; var x,a,b,c,i: integer; begin cls; write('введите число: '); readln(x); a: = x div 100; b: = (x - a*100) div 10; c: = (x - a*100 - b*10); if (a=b) or (a=c) or (b=c) then writeln('есть одинаковые цифры') else writeln('одинаковых цифр нет'); end.2)uses crt; var x: real; begin cls; write('сумма покупки: '); readln(x); if x> 1000 then x: =x-(x*0.1); writeln('стоимость с учётом возможной скидки ',x); end.
#include <iostream>
#include <ctime>
using namespace std;
int main() {
const int n = 4;
float arr[n][10];
cout << "Исходный массив: " << endl;
srand(time(NULL));
for (int i = 0; i < n; i++){
for (int j = 0; j < 10; j++){
float minValue = -10.f;
float maxValue = 10.f;
arr[i][j] = (float)rand()/(float) RAND_MAX * (maxValue - minValue) + minValue;
cout << arr[i][j] << " ";
}
cout << endl;
}
int maxIndex = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < 10; j++)
if (arr[i][j] >= arr[maxIndex/10][maxIndex%10])
maxIndex = i * 10 + j;
cout << "Max: " << "arr["<<maxIndex/10<<"]["<<maxIndex%10<<"] = "
<< arr[maxIndex/10][maxIndex%10] << endl;
int row = maxIndex/10;
if (row < n - 1){
cout << "Меняем " << row + 1 << " и " << n << " строки местами: " << endl;
for (int j = 0; j < 10; j++){
float temp = arr[n-1][j];
arr[n-1][j] = arr[row][j];
arr[row][j] = temp;
}
for (int i = 0; i < n; i++){
for (int j = 0; j < 10; j++)
cout << arr[i][j] << " ";
cout << endl;
}
} else {
cout << "Максимальный элемент находится на последней строке." << endl;
}
return 0;
}