Відповідь:
Целое число это число у которого нету цифр после запятой
Рассмотрим все варианты
Функция abs это модуль из математики тоесть если в функцию abs передается целое число то и возвращаеться тоже целое
5*2 Звездочка обозначает обычную операцию умножения тоесть 5*2 = 10, а 10 это целое число
Функция round создана для того чтобы округлять число до заданной длины,тоесть в функцию передается два значения само число которое надо округлить,и длина. Длина у нас 2, так что число не будет целым
5/2.0 Возвращает не целое число
Тоесть ответ : abs(-25) 5*2
Пояснення:
Відповідь:
1.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void randarr(int *A, int N){
for(int i = 0; i < N; i++){
A[i] = rand() % 10 + 1;
}
}
void printarr(int *A, int N){
for(int i = 0; i < N; i++){
cout << A[i] << " ";
}
}
void sortarr(int *A, int N){
for(int i = 0; i < N; ++i){
int smallest = i;
for(int j = i + 1; j < N; ++j){
if(A[j] < A[smallest]){
smallest = j;
}
}
swap(A[i] , A[smallest]);
}
}
int main(){
srand(time(NULL));
setlocale(LC_ALL, "Rus");
int N;
cout << "Введите кол-во елементов массива: ";
cin >> N;
int *A = new int[N];
randarr(A,N);
printarr(A,N);
sortarr(A,N);
cout << "\n";
printarr(A,N);
delete[] A;
return 0;
}
2.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void randarr(int *B, int N){
for(int i = 0; i < N; i++){
B[i] = rand() % 10 + 1;
}
}
void printarr(int *B, int N){
for(int i = 0; i < N; i++){
cout << B[i] << " ";
}
}
void sortarr(int *B, int N){
int twoelements;
for(int j = 0; j < N - 1; j++){
twoelements = j;
}
swap(B[0] , B[twoelements]);
}
int main(){
srand(time(NULL));
setlocale(LC_ALL, "Rus");
int N;
cout << "Введите кол-во елементов массива: ";
cin >> N;
int *B = new int[N];
randarr(B,N);
printarr(B,N);
sortarr(B,N);
cout << endl;
printarr(B,N);
delete[] B;
return 0;
}
3.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
void randarr(int *A, int N){
for(int i = 0; i < N; i++){
A[i] = rand() % 10 + 1;
}
}
void printarr(int *A, int N){
for(int i = 0; i < N; i++){
cout << A[i] << " ";
}
}
void twoarr(int *A, int *B, int N){
for(int i = 0; i < N; i++){
B[i] = A[i] * (-1);
}
}
void sortarrtobig(int *A, int N){
for(int i = 0; i < N; ++i){
int smallest = i;
for(int j = i + 1; j < N; ++j){
if(A[j] < A[smallest]){
smallest = j;
}
}
swap(A[i] , A[smallest]);
}
}
void sortarrtosmall(int *A, int N){
for(int i = 0; i < N; ++i){
int smallest = i;
for(int j = i + 1; j < N; ++j){
if(A[j] > A[smallest]){
smallest = j;
}
}
swap(A[i] , A[smallest]);
}
}
int main(){
srand(time(NULL));
setlocale(LC_ALL, "Rus");
int N;
cout << "Введите кол-во елементов массива: ";
cin >> N;
int *A = new int[N];
int *B = new int[N];
randarr(A,N);
cout << "Первый массив: ";
printarr(A,N);
cout << "\nВторой массив: ";
twoarr(A,B,N);
printarr(B,N);
cout << "\nСортируем первый массив по убыванию" << endl;
sortarrtosmall(A,N);
cout << "Первый массив: ";
printarr(A,N);
cout << "\nСортируем второй массив по возрастанию" << endl;
sortarrtobig(B,N);
cout << "Второй массив: ";
printarr(B,N);
delete[] A;
delete[] B;
return 0;
}
Поделитесь своими знаниями, ответьте на вопрос:
Цикл с параметром в паскале. найти все двузначные числа, в записи которых есть цифра 5