М
Молодежь
К
Компьютеры-и-электроника
Д
Дом-и-сад
С
Стиль-и-уход-за-собой
П
Праздники-и-традиции
Т
Транспорт
П
Путешествия
С
Семейная-жизнь
Ф
Философия-и-религия
Б
Без категории
М
Мир-работы
Х
Хобби-и-рукоделие
И
Искусство-и-развлечения
В
Взаимоотношения
З
Здоровье
К
Кулинария-и-гостеприимство
Ф
Финансы-и-бизнес
П
Питомцы-и-животные
О
Образование
О
Образование-и-коммуникации
selihanova
selihanova
25.05.2021 14:04 •  Информатика

Нужно сделать программу на С.


Нужно сделать программу на С.

👇
Открыть все ответы
Ответ:
вопрос210
вопрос210
25.05.2021

Відповідь:

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;

}

4,8(36 оценок)
Ответ:
tatstryukova
tatstryukova
25.05.2021

відповідь: function showresult(choise){

var n1=parsefloat(document.getelementbyid('num1').value);

var n2=parsefloat(document.getelementbyid('num2').value);

var r;

var c=choise;

switch(c)

{

case '1':

  r=n1+n2;

  break;

case '2':

  r=n1-n2;

  break;

case '3':

  r=n1*n2;

  break;

case '4':  

  r=n1/n2;

  break;

case '5':

  r=n2*100/n1;

  break;

default:

  break;

   

}

document.getelementbyid('result').value=r;

 

}

calculator

my calculator first number second number result

+

-

*

/

%

пояснення:

4,5(58 оценок)
Это интересно:
Новые ответы от MOGZ: Информатика
logo
Вход Регистрация
Что ты хочешь узнать?
Спроси Mozg
Открыть лучший ответ