New course! Every coder should learn Generative AI!
Try a free lesson+ 3
SOS๐ข
I wrote this code that arranges a group of numbers, but there is something bothering me about it. Here the user has to enter the number of numbers. Can I exempt him from that https://code.sololearn.com/cjG63TbXmYlP/?ref=app
3 Answers
+ 5
Thanks man I didn't know about this vector thing
It didn't work at first put after some searching i solved the problem
You should use the header
#include <vector>
+ 4
Do you mean trouble in entering in input?
Add input line by line or space separated. Ex:
3
2 5 4
// 3 is n value, next values are into array .
Or, you want to remove n input?
Actually,
Variable size arrays are recommended to use. You can use vector instead.
So better to use as :
int main() {
int n,x;
//cin >>n;
int free;
//int arr [n];
vector<int> arr;
while(cin >>x )
arr.push_back(x);
n = arr.size();
// continue your loop..
//...
//...
+ 3
Yes. I should also mentioned about the header. You are found it well๐
You're welcome...