Возможно ли иметь такой код?
не могли бы вы сказать мне, пожалуйста, почему это возможно иметь такие коды?
#include <iostream>
using namespace std;
int main()
{
int arr[4][4];
int a, b;
int temp;
cout << "Enter four numbers: \n";
for (a=0; a<4; a++)
{
cin >> arr[a][a]; >especially in this case is it alright to have code like this and why? because i was so confuse why is it okay to have a code like that
}
cout << endl;
cout <<"Even numbers: \n";
for (a=0;a<4;a++)
{
if (arr[a][a]%2==0)
{
cout << arr[a][a]<<endl;
}
}
cout << endl;
cout << "Highest to lowest: "<< endl;
for (a=0; a<4;a++)
{
for (b=a+1;b<4;b++)
{
if (arr[a][a]<arr[b][b])
{
temp=arr[a][a]; >and also can you please explain how sorting works?
arr[a][a]=arr[b][b];
arr[b][b]=temp;
}
}
}
for(a=0;a<4;a++)
{
if (arr[a][a]%2==0)
{
cout<<arr[a][a]<<endl;
}
}
return 0;
}
I'm sorry if I ask too much because I was a beginner in programming :< thank you
Что я уже пробовал:
Я пробовал этот код, но не ожидал, что он будет работать
Patrice T
Откуда у тебя этот код ?
jusjua
Я просто сделал его сам, потому что это было лабораторное занятие в моей школе