title: Problem with sort algorithm(buying shop items)(Crashing)
body: <p>I have problem about little bit complex problem with sorting algorithm.
  And my program non-stop crashing(sorry i'm bad at English). The goal of program
  is to buy (from budget) most expensive item and sort every item to the list but, as you can see i'm suck at this and get an a crash from program(again sorry for rude).</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
  double pare; //budget
  int n; //numbers of articles
  cin&gt;&gt;pare&gt;&gt;n;
  
  string kod[n];//name of article
  
  bool check[n]; //checker
  
  double cena[n]; //price
  
  int m,j; //max and extend for him(j)
  m=cena[1];
  j=0;
  
   for(int b = 0; b&lt;n;b++){ //input
        cin&gt;&gt;cena[b];
  }
  
  
  for(int x = 0; x&lt;n;n++){
      if(cena[x]==pare){
          pare-=cena[x];
  
             check[x] = true;
           }else if(cena[x]&gt;pare){
               check[x] = false;
  
           }else if(cena[x] &lt; pare){
                  check[x] = true;
           }
  
  for(int i2 = 0;i2&lt;n;i2++){
      if(cena[i2] == true){
          if(m&lt;cena[i2]){
              m=cena[i2];
              j=m;
          }
      }
  }
   pare-=j;
  
  }
  
   for(int i3 = 0; i3&lt;n;i3++){   //output
       if(check[i3] == true){
          cout&lt;&lt;kod[i3]&lt;&lt; " " &lt;&lt; cena[i3]&lt;&lt;endl;
      }
   }
   if(pare&gt;0){
      cout&lt;&lt;pare&lt;&lt;endl;
   }
  
  
  
  
  return 0;
  }
  </code></pre>
  
  <p>Sorry if i something miss.</p>