Şimdi Ara

Yönsüz graf c++ kodu

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
2
Cevap
0
Favori
365
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Yönsüz bir graftaki bütün alt bileşenleri ve düğümlerini tespit eden bir program yazınız. 


    Alt Bileşen Düğümler

    1 1,3,5,7,9

    2 2,4,10,12,6


    Çıktı bu şekilde olacak.

    Ben kodu yazdım ama hatalar alıyorum bakabilir misiniz?


    #include <iostream>

    #include <iomanip>

    //#include <locale.h> //


    using namespace std;

    int main (){

    int sdizi[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    int sycc=1;

    bool buluc(int dizi[], int sayi);

    sdizi[0]=1;

    short graph[20]

    [20]={{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

    {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},

    {0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0},

    {0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0},

    {0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0},

    {0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},

    {0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0},

    {0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0},

    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},

    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0}};

    for (int i=0 ; i<20 ; i++)

    {

    for (int j=0 ; j<20 ; j++)

    {

    if(graph[i][j]!= 0)

    {

    if(buluc(sdizi,j+1))

    sdizi[sycc]=j+1; sycc++;}

    }

    }

    }


    //setlocale(LC_ALL, "Turkish");

    cout << endl << "alt_bilesen" << setw(10) << "dugumler" < endl << endl; (burada hata alıyorum coutta)

    cout << setw(6) << 1 << setw(4) << " "; (burada hata alıyorum coutta)

    for(int m=0 ; m<20 ; m++) (for da ve m lerde hata alıyorum)

    {

    if(sdizi[m]>0 && sdizi[m]<21) cout << setw(4) << sdizi[m];}

    return 0 ; (burada hata alıyorum)

    } (bide burada hata)

    bool buluc(int dizi[], int sayi){

    for(int i=0 ; i<20 ; i++){

    if(dizi[i] == sayi) return false;}

    return true;

    }








  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.