Answer the question
In order to leave comments, you need to log in
How to fix the displayed errors C2109 and C2676?
Gosvo" does not define this operator or type conversion is acceptable to built-in operator
An array or pointer is required for index
All errors at the end of code in loop lines
#include <iostream>
using namespace std;
enum stran {
Belarus, Brasiliya, Iran
};
union no {
int people;
int s;
};
struct Gosvo
{
no a;
char name:30;
char sity;
stran b;
};
int main()
{
setlocale(LC_ALL, "Russian");
Gosvo f;
f.a.people = 9;
f.name = Belarus;
f.a.s = 2;
Gosvo k;
k.a.people=213;
k.name = Brasiliya;
k.a.s=8;
Gosvo l;
l.a.people = 83;
l.name = Iran;
l.a.s = 16;
Gosvo gosvos[3];
gosvos[0] = f;
gosvos[1] = k;
gosvos[2] = l;
int n;
cout << "Введите количество структур в массиве:";
cin >> n;
for (int i = 0; i <= n; i++) {
for (int j = 0; j < n - 1; j++)
{
if (gosvos[j] > gosvos[j + 1])
{
int b = gosvos->name[j]; // создали дополнительную переменную
gosvos->name[j] = gosvos->name[j + 1]; // меняем местами
gosvos->name[j + 1] = b; // значения элементов
}
}
cout << gosvos->name[i] << " "; // выводим элементы массива
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question