12266 | 2024-12-10 20:30:58 | feheristvan | Mekk Mester munkái (50 pont) | cpp17 | Compilation error |
#include <iostream>
#include <fstream>
using namespace std;
struct elem{
int kezd, veg, index;
};
void be(int &n, int &h, elem a[])
{
// ifstream fin("szoveg.in");
cin >> n >> h;
for(int i=0;i<n;i++)
{
cin >> a[i].kezd >> a[i].veg;
a[i].index=i+1;
}
// fin.close();
}
void buborek(int n, elem a[])
{
int csere=n-1,akt_csere;
do{
akt_csere=0;
for(int i=0;i<csere;i++)
{
if(a[i].veg>a[i+1].veg)
{
swap(a[i],a[i+1]);
akt_csere=i;
}
}
csere=akt_csere;
}while(csere!=0);
}
void kiir(int n, elem a[])
{
// ofstream fout("szoveg.out");
int vege_apa=a[0].veg;
int vege_fia = a[1].veg;
int apa[100000], fia[100000], db_a = 1, db_f = 1;
apa[0] = a[0].index;
fia[0] = a[1].index;
for(int i=2;i<n;i++)
{
if(a[i].kezd > vege_apa)
{
vege_apa=a[i].veg;
apa[db_a] = a[i].index;
db_a ++;
} else if(a[i].kezd > vege_fia){
vege_fia = a[i].veg;
fia[db_f] = a[i].index;
db_f ++;
}
}
cout << db_a << " " << db_f << endl;
buborek(apa);
for(int i = 0; i < db_a; i ++){
cout << apa[i] << " ";
}
buborek(fia);
cout << endl;
for(int i = 0; i < db_f; i ++){
cout << fia[i] << " ";
}
// fout.close();
}
int main()
{
int n,h;
elem a[100000];
be(n,h,a);
buborek(n,a);
kiir(n,a);
return 0;
}
open /var/local/lib/isolate/400/box/a.out: no such file or directory
main.cpp: In function 'void kiir(int, elem*)':
main.cpp:63:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
63 | buborek(apa);
| ^~~
| |
| int*
main.cpp:63:11: error: too few arguments to function 'void buborek(int, elem*)'
63 | buborek(apa);
| ~~~~~~~^~~~~
main.cpp:23:6: note: declared here
23 | void buborek(int n, elem a[])
| ^~~~~~~
main.cpp:67:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
67 | buborek(fia);
| ^~~
| |
| int*
main.cpp:67:11: error: too few arguments to function 'void buborek(int, elem*)'
67 | buborek(fia);
| ~~~~~~~^~~~~
main.cpp:23:6: note: declared here
23 | void buborek(int n, elem a[])
| ^~~~~~~