9031 2024. 02. 12 12:27:33 akososka Leggyorsabb pénzkeresés (50) cpp17 Forditási hiba
#include <iostream>
#include <fstream>

using namespace std;
int n,m;
int main()
{
    cin>>n;
    cin>>m;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int k,s=INT_MAX,q,i=1,j;
    while(i<=n){
        k=0;
        j=0;
        while(k<=m){j++;k=k+a[j];}
        j--;
        if(k>=m)i=n+1;
        if(j<s && k>=m){s=j;q=i;}
        i++;
    }
    cout<<s;
    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:14:13: error: 'INT_MAX' was not declared in this scope
   14 |     int k,s=INT_MAX,q,i=1,j;
      |             ^~~~~~~
main.cpp:3:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <fstream>
  +++ |+#include <climits>
    3 | 
main.cpp:15:11: error: 'i' was not declared in this scope
   15 |     while(i<=n){
      |           ^
main.cpp:17:9: error: 'j' was not declared in this scope
   17 |         j=0;
      |         ^
main.cpp:21:29: error: 'q' was not declared in this scope
   21 |         if(j<s && k>=m){s=j;q=i;}
      |                             ^
Exited with error status 1