No output

Why does this don't output anything?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <vector>

using  namespace std;
int main()
{
    int num=0;
    std::cin>>num;
            std::vector<int> bolas;
            std::vector<int> posibilidades;
            for(int n=0;n<num;n++)
            {
                std::cin>>bolas[n];
            }
            int temp=0;
            for(int q=0;q<num;q++)
            {
                for(int w=0;w<num-1;w++)
                {
                    if(bolas[w]>bolas[w+1])
                    {
                        bolas[w]=temp;
                        bolas[w]=bolas[w+1];
                        bolas[w+1]=temp;
                    }
                }
                
            }
            for(int i=0;i<num;i++)
            {
            std::cout<<bolas[i]<<" ";    
            }
            
    
            
        
}
First, you vector has no size. Change line 9 to
std::vector<int> bolas(num);



Second,
temp is used as temporary storage.
It needs to be set to its relevant value; i.e. temp=...

So have a look at the line 22
bolas[w]=temp;

Do you think that is right? Which variable are you setting the value of?



There's a few other cosmetic problems. For example, you have no need of posibilidades, and your indentation is screwed up (probably by tabs).
Last edited on
It doesn’t output anything because yabi is just taking the piss.
Topic archived. No new replies allowed.