Language: C


    return aNum - bNum;
}
int main(void){
  int n, x;
  int a[105];
  scanf("%d %d", &n,&x);
  
  //int sum = 0;
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    //sum+=a[i];
  }
  /*
  if(x>sum){
    printf("%d", n-1); 
    return 0;
  }
  */
  
  
  qsort(a, n, sizeof(int), compareInt);
  int i,s=0;int ans=0;
  for(i=0;i<n&&s<=x;i++){
    s+=a[i];
  }
    if(s==x && i==n){
      ans = n;     
    }else if(s!=x && i==n){
      ans = n-1;      
    }
  else if(i!=n){
    ans = i-1;
  }
  printf("%d", ans);
  return 0;
}
  
    return aNum - bNum;
}
int main(void){
  int n, x;
  int a[105];
  scanf("%d %d", &n,&x);
  
  //int sum = 0;
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    //sum+=a[i];
  }
  /*
  if(x>sum){
    printf("%d", n-1); 
    return 0;
  }
  */
  
  
  qsort(a, n, sizeof(int), compareInt);
  int i,s=0;int ans=0;
  for(i=0;i<n&&s<=x;i++){
    s+=a[i];
  }
    if(s==x && i==n){
      ans = n;     
    }else if(s!=x && i==n){
      ans = n-1;      
    }
  else if(i!=n){
    ans = i-1;
  }
  printf("%d", ans);
  return 0;
}
  

Compiler output:
main.c:2:5: error: expected identifier or '(' before 'return'
    2 |     return aNum - bNum;
      |     ^~~~~~
main.c:3:1: error: expected identifier or '(' before '}' token
    3 | }
      | ^
main.c: In function 'main':
main.c:7:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    7 |   scanf("%d %d", &n,&x);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:7:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    7 |   scanf("%d %d", &n,&x);
      |   ^~~~~
main.c:7:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:22:3: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
   22 |   qsort(a, n, sizeof(int), compareInt);
      |   ^~~~~
main.c:22:28: error: 'compareInt' undeclared (first use in this function)
   22 |   qsort(a, n, sizeof(int), compareInt);
      |                            ^~~~~~~~~~
main.c:22:28: note: each undeclared identifier is reported only once for each function it appears in
main.c:35:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   35 |   printf("%d", ans);
      |   ^~~~~~
main.c:35:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:35:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:35:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: At top level:
main.c:39:5: error: expected identifier or '(' before 'return'
   39 |     return aNum - bNum;
      |     ^~~~~~
main.c:40:1: error: expected identifier or '(' before '}' token
   40 | }
      | ^
main.c:41:5: error: redefinition of 'main'
   41 | int main(void){
      |     ^~~~
main.c:4:5: note: previous definition of 'main' with type 'int(void)'
    4 | int main(void){
      |     ^~~~
main.c: In function 'main':
main.c:44:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   44 |   scanf("%d %d", &n,&x);
      |   ^~~~~
main.c:44:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:59:28: error: 'compareInt' undeclared (first use in this function)
   59 |   qsort(a, n, sizeof(int), compareInt);
      |                            ^~~~~~~~~~
main.c:72:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   72 |   printf("%d", ans);
      |   ^~~~~~
main.c:72:3: note: include '<stdio.h>' or provide a declaration of 'printf'