whats error in this code
Code
hi @discobot a lot of mistakes
u can refer
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n,s;
cin>>n; // first take array size
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
}
int x;
cin>>x; // then take target
for(int i = 0; i<=n-1; i++){
for(int j =i+1; j <=n-1; j++){ // <= n-1
s = a[i]+a[j];
if(s == x){
cout<<min(a[i], a[j])<<" and "<<max(a[i], a[j])<<endl; // print minimum value first
}
}
}
return 0;
}
Hi! To find out what I can do, say @discobot display help
.
why use #include<>
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.