标题:新手求助: error: ld returned 1 exit status (code::blocks软件)
只看楼主
彩袅
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-5-18
结帖率:0
已结贴  问题点数:20 回复次数:4 
新手求助: error: ld returned 1 exit status (code::blocks软件)
||=== Build: Debug in Theorie des Graphes (compiler: GNU GCC Compiler) ===|
||error: ld returned 1 exit status|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
望高人指教
目前代码还没有完成,还没对S做操作。 目前做的是给donneesi中的Mi[mi][ni]的M[j][k]边上色
图着色问题
需要用c语言
我换了台电脑试过还是有问题所以应该不是硬件问题。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "donnees1.h"
#include "donnees2.h"
#include "donnees3.h"

int row,col;

void swap (int A,int B)
    {
    int temp;
    temp=A;
    A=B;
    B=temp;
    }

int max(int a,int b)
    {
    int MAX;
    MAX=(a>b ? a:b);
    return MAX;
    }

int NombredeCour(int B[row][col])
    {
    int i,j;
    int A[row][col];
    for (i=0;i<m1;i++)
        {
        for (j=0;j<n1;j++)
            A[i][j]=B[i][j];
        }
    int Nombremax=0;
    int Nombredecour[row];
    memset(Nombredecour,0,10);
    for (i=0;i<row;i++)
        {
        for (j=0;j<col;j++)
            {
            while (A[i][j]!=0)
                {
                A[i][j]--;
                Nombredecour[i]++;
                }
            }
        Nombremax=max(Nombremax,Nombredecour[i]);
        }
    return Nombremax;
    }

void AreteColoration(int A[row][col])
    {
    int i,j;
    int k,K;
    int l,L;
    int n,N,Imax;
    int Adj[row+1];
    Adj[0]=0;
    int Arete[row*col][2];
    k=0;
    for (i=0;i<row;i++)//creation d une matrice contenant les aretes du graphe
        {
        for (j=0;j<col;j++)
            {
            if (A[i][j]!=0)
                {
                Arete[k][1]=i;
                Arete[k][2]=j;
                Adj[i+1]++;
                k++;
                }
            }
        }
    K=k;
    L=K;
    for (k=0;k<K;k++) // On est dans un graphe non oriente
        {             // donc elimination des arete j-i si il y a deja i-j
        for (l=0;l<K;l++)
            {
            if (Arete[l][1]==0 && Arete[l][2]==0)
                {
                swap(Arete[l][1],Arete[l+1][1]);
                swap(Arete[l][2],Arete[l+1][2]);
                }
            if (k!=l && Arete[k][1]==Arete[l][2] && Arete[k][2]==Arete[l][1])
                {
                Arete[l][1]=0;
                Arete[l][2]=0;
                L--;
                }
            if (Arete[l][1]==0 && Arete[l][2]==0)
                {
                swap(Arete[l][1],Arete[l+1][1]);
                swap(Arete[l][2],Arete[l+1][2]);
                }
            }
        }
    K=L;
    k=0;
    n=0;
    int Coloration[K];
    int Temps[K][row*col];
    memset(Coloration,0,10);
    for (i=0;i<row;i++)
        {
        n=n+Adj[i];
        Coloration[n]=1;
        }
    N=NombredeCour(A);
    for (k=1;k<K;k++)
        {
        for (i=0;i<row;i++)
            {
            if (Arete[i][2]!=Arete[k][2] && A[Arete[i][1]][Arete[k][2]]!=0 && Coloration[i]!=0)
                {
                Coloration[k]++;
                if (Coloration[k]==Coloration[i] && i!=k)
                    {
                    if (Coloration[k]==N)
                        Coloration[k]=1;
                    else
                        Coloration[k]++;
                    }
                }
            }
        for (j=0;j<col;j++)
            {
            if (Arete[j][1]!=Arete[k][1] && A[Arete[k][1]][Arete[j][2]]!=0 && Coloration[j]!=0)
                {
                if (Coloration[k]>=N)
                    Coloration[k]=1;
                else
                    Coloration[Arete[k][1]]++;
                if (Coloration[k]==Coloration[j] && j!=k)
                    {
                    if (Coloration[k]>=N)
                        Coloration[k]=1;
                    else
                        Coloration[Arete[k][1]]++;
                    }
                }
            }
        }
    Imax=0;
    for (l=0;l<N;l++)       // A l horaire [couleur]
        {                   // les collones impaires correspondent aux professeurs
        i=0;                // les collones paires correspondent aux classes
        for (k=0;k<K;k++)
            {
            if (Coloration[k]==l)
                {
                Temps[Coloration[k]][i]=Arete[k][1];
                i++;
                Temps[Coloration[k]][i]=Arete[k][2];
                i++;
                }
            Imax=max(Imax,i);
            }
        }
    for (l=0;l<N;l++)
        {
        for (k=0;k<Imax;k++)
            printf("%d ",Temps[l][k]);
        printf("\n");
        }
    for (k=0;k<K;k++)
        {
        printf("%d->%d couleur %d\n",Arete[k][1],Arete[k][2],Coloration[k]);
        }
    }

int main()
    {
    int i,j,k;
    int N;
    scanf("%d", &N);// Numero de donnees choisies
    if (N==1)
        {
        int m=m1;
        int n=n1;
        int q=q1;
        int M[m][n];
        int S[m][q];
        for (i=0;i<m;i++)
            {
            for (j=0;j<n;j++)
                M[i][j]=M1[i][j];
            for (k=0;k<q;k++)
                S[i][k]=S1[i][k];
            }
        row=m;
        col=n;
        AreteColoration(M);
        }
    else if (N==2)
        {
        int m=m2;
        int n=n2;
        int q=q2;
        int M[m][n];
        int S[m][q];
        for (i=0;i<m;i++)
            {
            for (j=0;j<n;j++)
                M[i][j]=M2[i][j];
            for (k=0;k<q;k++)
                S[i][k]=S2[i][k];
            }
        row=m;
        col=n;
        AreteColoration(M);
        }
    else if (N==3)
        {
        int m=m3;
        int n=n3;
        int q=q3;
        int M[m][n];
        int S[m][q];
        for (i=0;i<m;i++)
            {
            for (j=0;j<n;j++)
                M[i][j]=M3[i][j];
            for (k=0;k<q;k++)
                S[i][k]=S3[i][k];
            }
        row=m;
        col=n;
        AreteColoration(M);
        }
    else  //If you want to test more cases
        {
        int m4=0,n4=0,q4=0;
        scanf("%d %d %d",&m4,&n4,&q4);
        int m=m4;
        int n=n4;
        int q=q4;
        int M[m][n];
        int S[m][q];
        for (i=0;i<m;i++)
            {
            for (j=0;j<n;j++)
                {
                scanf("%d",&M[i][j]);
                }
            for (j=0;j<q;j++)
                {
                scanf("%d",&S[i][j]);
                }
            }
        row=m;
        col=n;
        AreteColoration(M);
        }
    }


[此贴子已经被作者于2018-5-19 06:38编辑过]

搜索更多相关主题的帖子: include int row for i++ 
2018-05-18 09:42
lin5161678
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:45
帖 子:1136
专家分:3729
注 册:2011-12-3
得分:20 
你之前编译运行弹出的运行界面没关闭

https://zh.
2018-05-18 09:58
彩袅
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-5-18
得分:0 
回复 2楼 lin5161678
是那个黑色的command 窗吗? 那个怎么关?
2018-05-18 13:49
lin5161678
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:45
帖 子:1136
专家分:3729
注 册:2011-12-3
得分:0 
右上角 或者 左上角 有一个 X 符号
点一下

PS 第一次回答怎么关闭软件的问题 好激动

https://zh.
2018-05-18 15:21
彩袅
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-5-18
得分:0 
回复 4楼 lin5161678
抱歉,没想到你说的是关软件。。。
试过了还是有问题。
请问代码本身有错吗?
2018-05-18 19:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-487039-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.609947 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved