радочкаУченик (208)
9 лет назад
cout<<"Ввод строки для сортировки: "<<endl;
cout<<"Введите № : ";
cin>>A;
cout<<"Результат массива после сортировки элемента строк по убыванию: "<<endl;
for (int k = 0; k < 6; k++){
for(int i = 0;i < 6; i++){
for (int j = 9-1; j > i; j--)
if (mas[k][j] > mas[k][j-1]){
int temp = mas[k][j];
mas[k][j] = mas[k][j-1];
mas[k][j-1] = temp;
#include
#include
using namespace std;
int main(){
setlocale(0,"");
int mas[6][9];
int temp, N=-100;
srand((unsigned)time(NULL));
cout<<"Начальный массив: "<<endl;
for(int i=0;i<6;i++){
for(int j=0;j<9;j++){
mas[i][j]=double(rand())/RAND_MAX*(200.+200.+1)-200.;
}
}
for(int i=0;i<6;i++){
for(int j=0;j<9;j++){
printf("%4d", mas[i][j]);
}
cout<<endl;
}
system("pause");
cout<<endl;
cout<<"Введите N: ";
cin>>N;
cout<<"Результат массива после замены элемента меньшие N:"<<endl;
for(int i=0;i<6;i++){
for(int j=0;j<9;j++){
if(mas[i][j]<N){
mas[i][j]=0;
}
else
continue;
}
}
for(int i=0;i<6;i++){
for(int j=0;j<9;j++){
printf("%4d", mas[i][j]);
}
cout<<endl;
}
int A;
system("pause");
cout<<endl;
cout<<"Ввод строки для сортировки: "<<endl;
cout<<"Введите № : ";
cin>>A;
cout<<"Результат массива после сортировки элемента строк по убыванию: "<<endl;
for (int k = 0; k < 6; k++){
for(int i = 0;i < 6; i++){
for (int j = 9-1; j > i; j--)
if (mas[k][j] > mas[k][j-1]){
int temp = mas[k][j];
mas[k][j] = mas[k][j-1];
mas[k][j-1] = temp;
}
}
}
for(int i=0;i<6;i++){
for(int j=0;j<9;j++){
printf("%4d", mas[i][j]);
}
cout<<endl;
}
system("pause");
return 0;
}