| 22455 | 2026-01-15 08:44:43 | mártonágnes | Megrendelések | cpp17 | Compilation error |
#include <iostream>
using namespace std;
struct munka
{
int sorsz;
int hido;
};
int M;
void rendez (munka m[])
{
int ind;
munka x[1];
for (int k=1; k<=M-1; k++)
{
int mini=INT_MAX;
for (int i=k; i<=M; i++)
{
if (m[i].hido<mini)
{
mini=m[i].hido;
ind=i;
}
}
if (ind!=k)
{
x[1]=m[k];
m[k]=m[ind];
m[ind]=x[1];
}
}
}
int main()
{
int N, K;
cin>>N>>M>>K;
munka m[M];
for (int i=1; i<=M; i++)
{
m[i].sorsz=i;
cin>>m[i].hido;
}
rendez(m);
for (int i=1; i<=M; i++)
{
cout<<m[i].hido<<" ";
}
int T=0, db=0, i=1, n=1;
while (n<N)
{
if (m[i].hido<=n && db<K)
{
m[i].hido=n;
db++;
i++;
}
if (m[i].hido>n || db==K)
{
T=T+db;
db=0;
n++;
}
}
cout<<T<<endl;
for (int i=1; i<=M; i++)
{
if (m[i].hido!=0)
{
cout<<m[i].sorsz<<" "<<m[i].hido<<endl;
}
}
return 0;
}
open /var/local/lib/isolate/430/box/a.out: no such file or directory
main.cpp: In function 'void rendez(munka*)':
main.cpp:17:18: error: 'INT_MAX' was not declared in this scope
17 | int mini=INT_MAX;
| ^~~~~~~
main.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
1 | #include <iostream>
+++ |+#include <climits>
2 |