Maximum subarray sum

It is asked in the question to take the input as Nspace seperated integers denoting the elements of array. HOW CAN I TAKE INPUT AS SPACE SEPERATION???

#include #include using namespace std; int maxSubArraySum(int a[], int size) { int max_so_far = INT_MIN, max_ending_here = 0; for (int i = 0; i < size; i++) { max_ending_here = max_ending_here + a[i]; if (max_so_far < max_ending_here) max_so_far = max_ending_here; if (max_ending_here < 0) max_ending_here = 0; } return max_so_far; } int main() { int a[100000],n,t,max_sum[100000]; cin>>t; cin>>n; for(int j=0;j<t;j++) { for(int i=0;i<n;i++) { cin>>a[i]; } max_sum[j] = maxSubArraySum(a, n); } for(int i=0;i<t;i++) { cout<<max_sum[i]<<endl; } return 0; } THIS IS MY CODE

@sharma.shubham
Just use cin. cin is able to take inputs separated by spaces or new line separately.