Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pomoc
Author Message
matijaivanus Offline
Novi korisnik
*

Posts: 51
Joined: Feb 2010
Reputation: 0
Post: #1
pomoc
Code:
#include<cstdlib>
#include<iostream>
#include<winbgim.h>
#include<ctime>
#include<fstream>
using namespace std;
int main(){
  int x,n,z;
  cout<<"koliko brojeva zelis sortirati"<<endl;
  cin>>n;
int p[n];
ofstream izlaz("podatci.txt");
cout<<"unesi brojeve"<<endl;
for(x=0;x<n;x++){
        cin>>p[x];
        }
        w:
        cout<<"upisi 1 za sortiranje od najveceg do najmanjeg"<<endl;
        cout<<"upisi 2 za sortiranje od najmanjeg do najveceg"<<endl;
        int a;
        cin>>a;
        switch (a){
               case 1:
        
        cout<<"sortiranje pocinje"<<endl;
        
        do{
        z=0;
for(x=0;x<n;x++){
        if(p[x]<p[x+1]){
              int y;
              y=p[x];
              p[x]=p[x+1];
              p[x+1]=y;
              z=1;}}}
              while(z==1);  
       cout<<"sortiranje zavrseno"<<endl;
        for(x=0;x<n;x++){              
        izlaz<<p[x]<<" ";
        }
        cout<<"ispis u podatci.txt"<<endl;
        cout<<"ispis na ekran"<<endl;
        for(x=0;x<n;x++){              
        cout<<p[x]<<endl;
        }
break;
         case 2:
                   cout<<"sortiranje pocinje"<<endl;
        
        do{
        z=0;
for(x=0;x<n;x++){
        if(p[x]>p[x+1]){
              int y;
              y=p[x];
              p[x]=p[x+1];
              p[x+1]=y;
              z=1;}}}
              while(z==1);  
       cout<<"sortiranje zavrseno"<<endl;
        for(x=0;x<n;x++){              
        izlaz<<p[x]<<" ";
        }
        cout<<"ispis u podatci.txt"<<endl;
        cout<<"ispis na ekran"<<endl;
        for(x=0;x<n;x++){              
        cout<<p[x]<<endl;
        }
        break;
        default:cout<<"pogresan unos"<<endl;
        goto w;
        }
system("pause");  
return 0;  
}
ak moze pomoc dok se izabere sortiranje od najmanjeg on postavi kao prvi rezultat nulu pa nabraja sve osom zadnjeg ak bi netko mogel pomoc cijenio bih to

Never argue with an idiot: first he will drag you down to his level, then he will beat you with experience.
14-11-2010 12:40 AM
Find all posts by this user Quote this message in a reply
zero Offline
Forumaš
***

Posts: 461
Joined: Jan 2008
Reputation: 10
Post: #2
RE: pomoc
http://www.tutorijali.net/forum/pravila-foruma-t-1.html


+ ako mozes bolje objasniti problem jer te nisam nista shvatio

Brzo. Jeftino. Kvalitetno. Izaberi dva!
14-11-2010 01:00 AM
Find all posts by this user Quote this message in a reply
matijaivanus Offline
Novi korisnik
*

Posts: 51
Joined: Feb 2010
Reputation: 0
Post: #3
RE: pomoc
zero Wrote:http://www.tutorijali.net/forum/pravila-foruma-t-1.html


+ ako mozes bolje objasniti problem jer te nisam nista shvatio

znaci dok u programu npr. oces sortirat 5 brojeva uzmimo da su to 8 9 5 6 7
i dok izaberemo opciju 2 sortiranje od najmanjeg prema najvecem
on sortira ovak 0 5 6 7 8 a trebalo bi biti 5 6 7 8 9
dok je za opciju 1 od najveceg prema najmanjem sve u redu
nadam se da si skuzil sad

Never argue with an idiot: first he will drag you down to his level, then he will beat you with experience.
14-11-2010 01:36 AM
Find all posts by this user Quote this message in a reply
Kerber Offline
_
*

Posts: 359
Joined: Dec 2006
Reputation: 1
Post: #4
RE: pomoc
imaš puno jednostavniji algoritam za ovo, previše si ispetljao :) nadam se da će me schmrz potvrditi :) dugo nisam compajlirao c++ :)

FGD!

Pravila foruma - pročitajte prije nego pitate
14-11-2010 02:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
matijaivanus Offline
Novi korisnik
*

Posts: 51
Joined: Feb 2010
Reputation: 0
Post: #5
RE: pomoc
Kerber Wrote:imaš puno jednostavniji algoritam za ovo, previše si ispetljao :) nadam se da će me schmrz potvrditi :) dugo nisam compajlirao c++ :)

znam alaj kad drugacije neznam

Never argue with an idiot: first he will drag you down to his level, then he will beat you with experience.
14-11-2010 02:45 AM
Find all posts by this user Quote this message in a reply
danielvast Offline
Forumaš
***

Posts: 432
Joined: Dec 2009
Reputation: 22
Post: #6
RE: pomoc
Mislim da je problem u tome sto ti područje provjere iskače iz područja unesenh članova liste ako umjesto if(p[x]>p[x+1]) postavis if(p[x]>p[x+1] & x+1 < n) (ili staviti for petlju da ide od 0 do n-1 for(i=0; i<n-1; i++))mislim da ce proraditi kako treba, btw ako zelis malo vise prouciti o naprednijim algoritmima za pretrazivanje/sortiranje mogu preporuciti ovaj link : http://www.tutorijali.net/forum/c-primje...l#pid10765 .

"When all else fails, read the manual."
(This post was last modified: 14-11-2010 11:28 AM by danielvast.)
14-11-2010 11:02 AM
Find all posts by this user Quote this message in a reply
matijaivanus Offline
Novi korisnik
*

Posts: 51
Joined: Feb 2010
Reputation: 0
Post: #7
RE: pomoc
ok hvala

Never argue with an idiot: first he will drag you down to his level, then he will beat you with experience.
14-11-2010 02:34 PM
Find all posts by this user Quote this message in a reply
danielvast Offline
Forumaš
***

Posts: 432
Joined: Dec 2009
Reputation: 22
Post: #8
RE: pomoc
Nema na cemu ... Namigivanje

"When all else fails, read the manual."
14-11-2010 02:38 PM
Find all posts by this user Quote this message in a reply
kecko Offline
Forumaš
***

Posts: 645
Joined: Nov 2009
Reputation: 20
Post: #9
RE: pomoc
Nekak sam alergičan na ove naslove... Teško je bilo napisati naprimjer "problem s programom za sortiranje" ili nešto tako...
Aj si zamisli da su svi takve naslove stavljaju na što bi to ličilo
14-11-2010 06:42 PM
Find all posts by this user Quote this message in a reply
marc1993 Offline
Novi korisnik
*

Posts: 3
Joined: Nov 2010
Reputation: 0
Post: #10
RE: pomoc
treban pomoc
ima li itko ideju kako napraviti program za povecanje *view na youtube*
16-11-2010 12:33 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)