الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مساعدة مستعجلة ، خطا واحد ويتنفد البرنامج

بدأه sandraab في 23 مارس 2012 · 8 رد · 450 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ارجو ممن لديهم خبرة المساعدة في اكتشاف الخطا وتصحيحه

انا احاول تنفيد خوارزمية فورد

maximum flow

Ford-Fulkerson algorithm

وبحثت في النت ووجدت كودات ولم استطيع تنفيد احدهم وكل واحد بيه خطا اقلها خطا واحد ارجو ممكن لديهم الخبرة المساعدة ، لانه عندي مشروع يجب ان اسلم الاسبوع المقبل

واول برنامج يحتوي خطا

too much global data defined in file

والرنامج هو :

#define WHITE 0

#define GRAY 1

#define BLACK 2

#define MAX_NODES 100

#define oo 1000000000

#include<stdio.h>

int n; // number of nodes

int e; // number of edges

int capacity[MAX_NODES][MAX_NODES]; // capacity matrix

int flow[MAX_NODES][MAX_NODES]; // flow matrix

int color[MAX_NODES]; // needed for breadth-first search

int pred[MAX_NODES]; // array to store augmenting path

int min (int x, int y) {

return x<y ? x : y; // returns minimum of x and y

}

int head,tail;

int q[MAX_NODES+2];

void enqueue (int x) {

q[tail] = x;

tail++;

color[x] = GRAY;

}

int dequeue () {

int x = q[head];

head++;

color[x] = BLACK;

return x;

}

int bfs (int start, int target) {

int u,v;

for (u=0; u<n; u++) {

color = WHITE;

}

head = tail = 0;

enqueue(start);

pred[start] = -1;

while (head!=tail) {

u = dequeue();

// Search all adjacent white nodes v. If the capacity

// from u to v in the residual network is positive,

// enqueue v.

for (v=0; v<n; v++) {

if (color[v]==WHITE && capacity[v]-flow[v]>0) {

enqueue(v);

pred[v] = u;

}

}

}

// If the color of the target node is black now,

// it means that we reached it.

return color[target]==BLACK;

}

int max_flow (int source, int sink) {

int i,j,u;

// Initialize empty flow.

int max_flow = 0;

for (i=0; i<n; i++) {

for (j=0; j<n; j++) {

flow[j] = 0;

}

}

// While there exists an augmenting path,

// increment the flow along this path.

while (bfs(source,sink)) {

// Determine the amount by which we can increment the flow.

int increment = oo;

for (u=n-1; pred>=0; u=pred) {

increment = min(increment,capacity[pred]-flow[pred]);

}

// Now increment the flow.

for (u=n-1; pred>=0; u=pred) {

flow[pred] += increment;

flow[pred] -= increment;

}

max_flow += increment;

}

// No augmenting path anymore. We are done.

return max_flow;

}

void read_input_file() {

int a,b,c,i,j;

FILE* input = fopen("mf.in","r");

// read number of nodes and edges

fscanf(input,"%d %d",&n,&e);

// initialize empty capacity matrix

for (i=0; i<n; i++) {

for (j=0; j<n; j++) {

capacity[j] = 0;

}

}

// read edge capacities

for (i=0; i<e; i++) {

fscanf(input,"%d %d %d",&a,&b,&c);

capacity[a] = c;

}

fclose(input);

}

int main () {

read_input_file();

printf("%d\n",max_flow(0,n-1));

return 0;

}

#include <string.h>

// the maximum number of vertices

#define NN 100

// adjacency matrix (fill this up)

int cap[NN][NN];

// flow network

int fnet[NN][NN];

// BFS

int q[NN], qf, qb, prev[NN];

int fordFulkerson( int n, int s, int t )

{

// init the flow network

memset( fnet, 0, sizeof( fnet ) );

int flow = 0;

while( true )

{

// find an augmenting path

memset( prev, -1, sizeof( prev ) );

qf = qb = 0;

prev[q[qb++] = s] = -2;

while( qb > qf && prev[t] == -1 )

for( int u = q[qf++], v = 0; v < n; v++ )

if( prev[v] == -1 && fnet[v] - fnet[v] < cap[v] )

prev[q[qb++] = v] = u;

// see if we're done

if( prev[t] == -1 ) break;

// get the bottleneck capacity

int bot = 0x7FFFFFFF;

for( int v = t, u = prev[v]; u >= 0; v = u, u = prev[v] )

bot <?= cap[v] - fnet[v] + fnet[v];

// update the flow network

for( int v = t, u = prev[v]; u >= 0; v = u, u = prev[v] )

fnet[v] += bot;

flow += bot;

}

return flow;

}

//----------------- EXAMPLE USAGE -----------------

int main()

{

memset( cap, 0, sizeof( cap ) );

int numVertices = 100;

// ... fill up cap with existing edges.

// if the edge u->v has capacity 6, set cap[v] = 6.

cout << fordFulkerson( numVertices, s, t ) << endl;

return 0;

}

#2

int Ford_Fulkelson(Vertex**& neighborMatrix, Node*& list,

int source, int terminal, const int& n)

{

int flowOverall =0 ;

int min = 0;

do

{

min = INFINITY;

searchAugmentation(neighborMatrix, list, source,terminal,min,n);

flowOverall += min;

}

while(min);

return flowOverall;

}

void searchAugmentation( Vertex**& neighborMatrix,

Node*& list, int source, int terminal, int& min, const int& n)

{

int* ancient;

int* color;

pListIt Q;

ancient = (int*) malloc ((n+1)*sizeof(int));

color = (int*) malloc ((n+1)*sizeof(int));

memset(ancient, 0, (n+1)*sizeof(int) );

memset(color , WHITE , (n+1)*sizeof(int) );

color[source] = GRAY;

ancient[source] = 0;

Q = NULL;

// put source into the queue

Q = (pListIt) malloc ( sizeof( ListIt));

Q->value = source;

Q->p_next = NULL;

int u = 0, v = 0;

pListIt at;

pListIt endQSe;

while(Q)

{

u = Q->value;

for( at = list.neighbors; at; at = at->p_next)

{

v = at->value;

if (color[v] == WHITE)

{

if (neighborMatrix[v].capacity != -1 && neighborMatrix[v].flowValue <

neighborMatrix[v].capicity)

{

color[v] = GRAY;

ancient[v] = u;

if (v == terminal)

{

improvement(neighborMatrix, terminal,ancient, min);

return; // stop the search as we found it

free(ancient);

free(color);

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

else

{

if (neighborMatrix[v].capacity != -1 && neighborMatrix[v].flowValue > 0)

{

color[v] = GRAY;

ancient[v] = -u;

if (v ==terminal)

{

improvement(neighborMatrix, terminal,ancient,min);

free(ancient);

free(color);

return;

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

}

}

}

//delete first item -> we visited all of its neighbors

endQSe = Q;

Q = Q->p_next;

free(endQSe);

color = BLACK; // paint it black

}

min = 0; // no improvement found, clean and return

free(ancient);

free(color);

}

void improvement(Vertex**& adiacentMatrix, int currentVertex, int*& ancient, int& minimal )

{

int vertexAt = 0;

if (ancient[currentVertex] < 0)

{

vertexAt = -ancient[currentVertex];

if (minimal > adiacentMatrix[currentVertex][vertexAt].flowValue)

{

minimal = adiacentMatrix[currentVertex][vertexAt].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[currentVertex][vertexAt].flowValue -= minimal;

}

else

{

if (ancient[currentVertex] > 0 )

{

vertexAt = ancient[currentVertex];

if (minimal > (adiacentMatrix[vertexAt][currentVertex].capacity - adiacentMatrix[vertexAt][currentVertex].flowValue ))

{

minimal = adiacentMatrix[vertexAt][currentVertex].capacity - adiacentMatrix[vertexAt][currentVertex].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[vertexAt][currentVertex].flowValue += minimal;

}

}

}

#3

وهدا برنامج ثالث به 6 اخطاء ارجو ممن لديه الخبرة ان يساعدني وبارك الله فيك جميعا

#include <stdio.h> // read/write

#include <stdlib.h> // dynamic memory allocation

#include <memory.h> // setting values for the arrays via the memory road

//----------------------------> Definations <-------------------------------

#define INFINITY 0X3F3F3F3F

#define WHITE 0X01010101

#define GRAY 0X02020202

#define BLACK 0X03030303

//#define VERBOSE

#define DIRECTED

// ---------------------------> Used structures <---------------------------

struct ListIt// A structure for the elements neighbor list

{

int value; // To which vertex we have a point ?

ListIt *p_next; // A pointer to the next vertex, if this is NULL no such thing exists

};

// Define a point for the type

typedef ListIt* pListIt;

// A representation for neighbor neighborMatrixix with some additional informations included

struct Vertex

{

int capicity; // capacity of the field

int flowValue; // the value of the flow

};

typedef Vertex* pVertex; // Pointer type of the vertex

// create for neighbor list type

struct Node

{

int vertexNr; // the sum of the in and the out

ListIt *neighboors;// the list of the neighbors

};

// ------------------> Declaration of functions <--------------------------

void read(Vertex**& neighborMatrix , int&n, Node*& list, int& fromP, int& endP);

bool add(pListIt &dest, int val); // Add a new vertex to_alfa the => pNod* vertexList; variable

void print(Vertex**& neighborMatrix , const int&n, Node*& list);

void improvement(Vertex**& neighborMatrix, int u, int*& ancient, int& min );

void searchAugmentation( Vertex**& neighborMatrix, Node*& list, int source, int terminal, int& min,const int& n);

int Ford_Fulkelson(Vertex**& neighborMatrix, Node*& list, int source, int terminal, const int& n);

void printImprovement(const int* const& ancient, const int curVertex);

int kConnectedEdge(Vertex**& neighborMatrix, Node*& list, const int& n);

void readConnectEdge(Vertex**& neighborMatrix , int&n, Node*& list);

void extractByPointGraph(Vertex**& neighborMatrix , int&n, Vertex**& toNeighborMatrix , Node*& toList);

int kConnectedVertex(Vertex**& neighborMatrix , int&n);

// -------------------> Main <-> Putting all togheter <----------------------

int main()

{

//create the variables

Vertex** mat;

int n; // the number of vertexes present in the graph

Node* list;

readConnectEdge(mat, n, list); // the data from the input file

print( mat, n, list); // the data we just read

printf(" \n\nThe input graphs edge connectivity is: %d", kConnectedEdge(mat, list,n));

printf(" \nThe input graphs node connectivity is: %d\n", kConnectedVertex(mat, n));

return 0;

}

// -----------------> Definition of the functions <--------------------------

//************************************

// Method: read -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// int & fromP

// int & endP

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:11

// Purpose: Read the data input

//************************************

void read(Vertex**& neighborMatrix, int&n, Node*& list, int& fromP, int& endP )

{

FILE* f;

freopen_s(&f,"Ford.in", "r", stdin);

freopen_s(&f,"Ford.out", "w", stdout);

fromP = -1;

endP = -1;

scanf("%d", &n);

scanf("%d%d", &fromP, &endP );

// now create vertex neighborMatrixix and list

// we will creat a little larger so we can read in indexing from 1

neighborMatrix = (Vertex**) calloc(n+1, sizeof(Vertex*));

int i =0; // local variable we are going to use

for( i = 1; i <= n; ++i)

{

neighborMatrix = (Vertex*) calloc(n+1, sizeof(Vertex));

}

int j =0;

for( i =1; i <= n; ++i)

for( j =1; j <= n; ++j)

neighborMatrix[j].capicity = -1;

// we will also create the list

list = (Node*) calloc(n+1, sizeof(Node)); // this will also initialize all the variables with 0

// Now read from the file and build up the structure of the Vertex neighborMatrixix and the list

int from,to, flowValue; // a couple of local variables used for data input

while( !feof(stdin)) // while we have for what to read

{

scanf("%d%d%d", &from, &to, &flowValue);

// we will increase now the capacity of both the input and output

neighborMatrix[from][to].capicity = flowValue;

#ifdef DIRECTED

neighborMatrix[to][from].capicity = flowValue;

#endif

// the flowValue counterpart will be set for all the values to 0 by the calloc

if(add(list[to].neighboors, from))

list[to].vertexNr++; // increase with one -> incoming edges

if(add(list[from].neighboors, to))

list[from].vertexNr++; // increase with one -> outgoing edges

}

}

//************************************

// Method: add -> public access

// Parameter\s:

// pListIt & dest

// int val

// Returns: bool

// Created by: Gábor Bernát -> 18:1:2009 11:12

// Purpose: Add another member to the list

//************************************

bool add(pListIt &dest, int val)

{

//create the item

pListIt p;

p = (pListIt) malloc(sizeof(ListIt));

p -> value = val;

if(!dest) // first item addition

{

p -> p_next = NULL;

dest = p;

}

else

{

pListIt find = dest;

pListIt at = NULL;

// first find the first greater number, insert before

while(find && find->value <= val)

{

if( find->value == val) // do not add a duplicate

{

free(p);

return false;

}

at = find;

find = find->p_next;

}

// insert at at

if (at) // insert at a valid point

{

p->p_next = at->p_next;

at->p_next = p;

}

else // insert at the start

{

p->p_next = dest;

dest = p;

}

}

return true;

}

//************************************

// Method: print -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:12

// Purpose: Print the content of the relevant arrays

//************************************

void print(Vertex**& neighborMatrix ,const int&n, Node*& list)

{

printf("\n The capacity \n");

int i =0, j =0;

for(i = 1 ; i <= n; ++i, printf("\n"))

for( j = 1; j <= n; ++j)

printf(" %d ", neighborMatrix[j].capicity);

printf("\n\n The neighbors: \n");

pListIt p;

for( i =1; i<=n; ++i, printf("\n"))

{

printf("%d ~ %d -> ", i, list.vertexNr);

p = list.neighboors;

while(p)

{

printf(" %d ", p->value);

p = p->p_next;

}

}

printf("\n\n");

}

//************************************

// Method: Ford_Fulkelson -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// int source

// int terminal

// const int & n

// Returns: int

// Created by: Gábor Bernát -> 18:1:2009 11:13

// Purpose: The algorithm

//************************************

int Ford_Fulkelson(Vertex**& neighborMatrix, Node*& list, int source, int terminal, const int& n)

{

int flowOverall =0 ;

int min = 0;

do

{

min = INFINITY;

searchAugmentation(neighborMatrix, list, source,terminal,min,n);

flowOverall += min;

}while(min);

return flowOverall;

}

//************************************

// Method: searchAugmentation -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// int source

// int terminal

// int & min

// const int & n

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:14

// Purpose: Find the shortest road next

//************************************

void searchAugmentation( Vertex**& neighborMatrix, Node*& list, int source, int terminal, int& min, const int& n)

{

int* ancient;

int* color;

pListIt Q;

ancient = (int*) malloc ((n+1)*sizeof(int));

color = (int*) malloc ((n+1)*sizeof(int));

memset(ancient, 0, (n+1)*sizeof(int) );

memset(color , WHITE , (n+1)*sizeof(int) );

color[source] = GRAY;

ancient[source] = 0;

Q = NULL;

// put source into the queue

Q = (pListIt) malloc ( sizeof( ListIt));

Q->value = source;

Q->p_next = NULL;

int u = 0, v = 0;

pListIt at;

pListIt endQSe;

while(Q)

{

u = Q->value;

for( at = list.neighboors; at; at = at->p_next)

{

v = at->value;

if (color[v] == WHITE)

{

if (neighborMatrix[v].capicity != -1 && neighborMatrix[v].flowValue < neighborMatrix[v].capicity )

{

color[v] = GRAY;

ancient[v] = u;

if (v == terminal)

{

#ifdef VERBOSE

printf("\n-Negative: ");

printImprovement(ancient,terminal);

#endif

improvement(neighborMatrix, terminal,ancient, min);

#ifdef VERBOSE

printf(" ----> with %d", min);

#endif

return; // stop the search as we found it

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

else

{

if (neighborMatrix[v].capicity != -1 && neighborMatrix[v].flowValue > 0)

{

color[v] = GRAY;

ancient[v] = -u;

if (v ==terminal)

{

#ifdef VERBOSE

printf("\n +Positive: ");

printImprovement(ancient,terminal);

#endif

improvement(neighborMatrix, terminal,ancient, min);

#ifdef VERBOSE

printf(" ----> with %d", min);

#endif

free(ancient);

free(color);

return;

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

}

}

}

//delete first item

endQSe = Q;

Q = Q->p_next;

free(endQSe);

color = BLACK;

}

min = 0; // no improvement found

free(ancient);

free(color);

}

//************************************

// Method: improvement -> public access

// Parameter\s:

// Vertex * * & adiacentMatrix

// int currentVertex

// int * & ancient

// int & minimal

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:15

// Purpose: Make the improvement

//************************************

void improvement(Vertex**& adiacentMatrix, int currentVertex, int*& ancient, int& minimal )

{

int vertexAt = 0;

if (ancient[currentVertex] < 0)

{

vertexAt = -ancient[currentVertex];

if (minimal > adiacentMatrix[currentVertex][vertexAt].flowValue)

{

minimal = adiacentMatrix[currentVertex][vertexAt].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[currentVertex][vertexAt].flowValue -= minimal;

}

else

{

if (ancient[currentVertex] > 0 )

{

vertexAt = ancient[currentVertex];

if (minimal > adiacentMatrix[vertexAt][currentVertex].capicity

- adiacentMatrix[vertexAt][currentVertex].flowValue )

{

minimal = adiacentMatrix[vertexAt][currentVertex].capicity

- adiacentMatrix[vertexAt][currentVertex].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[vertexAt][currentVertex].flowValue += minimal;

}

}

}

//************************************

// Method: printImprovement -> public access

// Parameter\s:

// const int * const & ancient

// const int vertex

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:15

// Purpose: Self explanatory

//************************************

void printImprovement(const int*const & ancient, const int vertex)

{

if (vertex)

{

if (vertex<0)

{

printImprovement(ancient, ancient[-vertex]);

printf(" %d ", -vertex); // the last item

}

else

{

printImprovement(ancient, ancient[vertex]);

printf(" %d ", vertex); // the last item

}

}

}

//************************************

// Method: kConnectedEdge -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// const int & n

// Returns: int

// Created by: Gábor Bernát -> 21:1:2009 0:08

// Purpose: Calculate how many edges can be deleted in a fashion that we maintain the connectivity

//************************************

int kConnectedEdge(Vertex**& neighborMatrix, Node*& list, const int& n)

{

int i = 0, j = 0, curKCon = 0;

int k = INFINITY;

for( i=1; i <= n-1; ++i)

for( j=i+1; j<= n; ++j)

{

int a =0, b = 0;

for (a = 1; a <= n; ++a)

for (b = 1; b <= n ; ++b)

{

neighborMatrix[a].flowValue = 0;

}

curKCon = Ford_Fulkelson(neighborMatrix, list, i , j, n);

if (curKCon < k)

{

k = curKCon;

}

}

return k;

}

//************************************

// Method: readConnectEdge -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: void

// Created by: Gábor Bernát -> 21:1:2009 0:16

// Purpose:

//************************************

void readConnectEdge(Vertex**& neighborMatrix, int&n, Node*& list )

{

FILE* f;

freopen_s(&f,"Ford.in", "r", stdin);

freopen_s(&f,"Ford.out", "w", stdout);

scanf_s("%d", &n);

// now create vertex neighborMatrixix and list

// we will creat a little larger so we can read in indexing from 1

neighborMatrix = (Vertex**) calloc(n+1, sizeof(Vertex*));

int i =0; // local variable we are going to use

for( i = 1; i <= n; ++i)

{

neighborMatrix = (Vertex*) calloc(n+1, sizeof(Vertex));

}

int j =0;

for( i =1; i <= n; ++i)

for( j =1; j <= n; ++j)

neighborMatrix[j].capicity = -1;

// we will also create the list

list = (Node*) calloc(n+1, sizeof(Node)); // this will also initialize all the variables with 0

// Now read from the file and build up the structure of the Vertex neighborMatrixix and the list

int from,to; // a couple of local variables used for data input

while( !feof(stdin)) // while we have for what to read

{

scanf_s("%d%d", &from, &to);

// we will increase now the capacity of both the input and output

neighborMatrix[from][to].capicity = 1;

#ifdef DIRECTED

neighborMatrix[to][from].capicity = 1;

#endif

// the flowValue counterpart will be set for all the values to 0 by the calloc

if(add(list[to].neighboors, from))

list[to].vertexNr++; // increase with one -> incoming edges

if(add(list[from].neighboors, to))

list[from].vertexNr++; // increase with one -> outgoing edges

}

}

//************************************

// Method: extractByPointGraph -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Vertex * * & toNeighborMatrix

// Node * & toList

// Returns: void

// Created by: Gábor Bernát -> 21:1:2009 1:27

// Purpose: Build up the extracted data sets

//************************************

void extractByPointGraph( Vertex**& neighborMatrix , int&n,Vertex**& toNeighborMatrix , Node*& toList )

{

int i =0;

int j =0;

// First allocate space for the items

toNeighborMatrix = (Vertex**) calloc(2*n+1, sizeof(Vertex*));

for( i = 1; i <= 2*n; ++i)

{

toNeighborMatrix = (Vertex*) calloc(2*n+1, sizeof(Vertex));

}

for( i =1; i <= 2*n; ++i)

for( j =1; j <= 2*n; ++j)

toNeighborMatrix[j].capicity = -1;

// we will also create the list

toList = (Node*) calloc(2*n+1, sizeof(Node)); // this will also initialize all the variables with 0

// fill the matrix and the list

for (i = 1; i <= n ; ++i) // divide

{

toNeighborMatrix[n+i].capicity = 1;

if( add(toList[n+i].neighboors, i ) )

{

++toList[n+i].vertexNr;

}

if( add(toList.neighboors, n+i ) )

{

++toList.vertexNr;

}

}

for (i = 1; i <= n ; ++i) // reconnect edges

for (j = 1; j <= n; ++j)

{

if (neighborMatrix[j].capicity != -1)

{

toNeighborMatrix[n+i][j].capicity = 1;

if( add(toList[n+i].neighboors, j ) )

{

++toList[n+i].vertexNr;

}

if( add(toList[j].neighboors, n+i ) )

{

++toList[j].vertexNr;

}

}

}

}

//************************************

// Method: kConnectedVertex -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: int

// Created by: Gábor Bernát -> 21:1:2009 1:42

// Purpose:

//************************************

int kConnectedVertex( Vertex**& neighborMatrix , int&n )

{

Vertex** extendedNeighborMatrix = NULL;

Node* extendedList = NULL;

extractByPointGraph(neighborMatrix, n, extendedNeighborMatrix, extendedList);

//print(extendedNeighborMatrix, 2*n, extendedList);

int k = INFINITY, curKCon = 0;

int i= 0, j = 0;

for( i=1; i <= n-1; ++i)

for( j=i+1; j<= n; ++j)

{

int a =0, b = 0;

for (a = 1; a <= 2*n; ++a)

for (b = 1; b <= 2*n ; ++b)

{

extendedNeighborMatrix[a].flowValue = 0;

}

extendedNeighborMatrix[n+i].capicity = INFINITY;

curKCon = Ford_Fulkelson(extendedNeighborMatrix, extendedList, i , j, 2*n);

extendedNeighborMatrix[n+i].capicity = 1;

if (curKCon < k)

{

k = curKCon;

}

}

return k;

}

وهدا برنامج ثالث به 6 اخطاء ارجو ممن لديه الخبرة ان يساعدني وبارك الله فيك جميعا

#include <stdio.h> // read/write

#include <stdlib.h> // dynamic memory allocation

#include <memory.h> // setting values for the arrays via the memory road

//----------------------------> Definations <-------------------------------

#define INFINITY 0X3F3F3F3F

#define WHITE 0X01010101

#define GRAY 0X02020202

#define BLACK 0X03030303

//#define VERBOSE

#define DIRECTED

// ---------------------------> Used structures <---------------------------

struct ListIt// A structure for the elements neighbor list

{

int value; // To which vertex we have a point ?

ListIt *p_next; // A pointer to the next vertex, if this is NULL no such thing exists

};

// Define a point for the type

typedef ListIt* pListIt;

// A representation for neighbor neighborMatrixix with some additional informations included

struct Vertex

{

int capicity; // capacity of the field

int flowValue; // the value of the flow

};

typedef Vertex* pVertex; // Pointer type of the vertex

// create for neighbor list type

struct Node

{

int vertexNr; // the sum of the in and the out

ListIt *neighboors;// the list of the neighbors

};

// ------------------> Declaration of functions <--------------------------

void read(Vertex**& neighborMatrix , int&n, Node*& list, int& fromP, int& endP);

bool add(pListIt &dest, int val); // Add a new vertex to_alfa the => pNod* vertexList; variable

void print(Vertex**& neighborMatrix , const int&n, Node*& list);

void improvement(Vertex**& neighborMatrix, int u, int*& ancient, int& min );

void searchAugmentation( Vertex**& neighborMatrix, Node*& list, int source, int terminal, int& min,const int& n);

int Ford_Fulkelson(Vertex**& neighborMatrix, Node*& list, int source, int terminal, const int& n);

void printImprovement(const int* const& ancient, const int curVertex);

int kConnectedEdge(Vertex**& neighborMatrix, Node*& list, const int& n);

void readConnectEdge(Vertex**& neighborMatrix , int&n, Node*& list);

void extractByPointGraph(Vertex**& neighborMatrix , int&n, Vertex**& toNeighborMatrix , Node*& toList);

int kConnectedVertex(Vertex**& neighborMatrix , int&n);

// -------------------> Main <-> Putting all togheter <----------------------

int main()

{

//create the variables

Vertex** mat;

int n; // the number of vertexes present in the graph

Node* list;

readConnectEdge(mat, n, list); // the data from the input file

print( mat, n, list); // the data we just read

printf(" \n\nThe input graphs edge connectivity is: %d", kConnectedEdge(mat, list,n));

printf(" \nThe input graphs node connectivity is: %d\n", kConnectedVertex(mat, n));

return 0;

}

// -----------------> Definition of the functions <--------------------------

//************************************

// Method: read -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// int & fromP

// int & endP

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:11

// Purpose: Read the data input

//************************************

void read(Vertex**& neighborMatrix, int&n, Node*& list, int& fromP, int& endP )

{

FILE* f;

freopen_s(&f,"Ford.in", "r", stdin);

freopen_s(&f,"Ford.out", "w", stdout);

fromP = -1;

endP = -1;

scanf("%d", &n);

scanf("%d%d", &fromP, &endP );

// now create vertex neighborMatrixix and list

// we will creat a little larger so we can read in indexing from 1

neighborMatrix = (Vertex**) calloc(n+1, sizeof(Vertex*));

int i =0; // local variable we are going to use

for( i = 1; i <= n; ++i)

{

neighborMatrix = (Vertex*) calloc(n+1, sizeof(Vertex));

}

int j =0;

for( i =1; i <= n; ++i)

for( j =1; j <= n; ++j)

neighborMatrix[j].capicity = -1;

// we will also create the list

list = (Node*) calloc(n+1, sizeof(Node)); // this will also initialize all the variables with 0

// Now read from the file and build up the structure of the Vertex neighborMatrixix and the list

int from,to, flowValue; // a couple of local variables used for data input

while( !feof(stdin)) // while we have for what to read

{

scanf("%d%d%d", &from, &to, &flowValue);

// we will increase now the capacity of both the input and output

neighborMatrix[from][to].capicity = flowValue;

#ifdef DIRECTED

neighborMatrix[to][from].capicity = flowValue;

#endif

// the flowValue counterpart will be set for all the values to 0 by the calloc

if(add(list[to].neighboors, from))

list[to].vertexNr++; // increase with one -> incoming edges

if(add(list[from].neighboors, to))

list[from].vertexNr++; // increase with one -> outgoing edges

}

}

//************************************

// Method: add -> public access

// Parameter\s:

// pListIt & dest

// int val

// Returns: bool

// Created by: Gábor Bernát -> 18:1:2009 11:12

// Purpose: Add another member to the list

//************************************

bool add(pListIt &dest, int val)

{

//create the item

pListIt p;

p = (pListIt) malloc(sizeof(ListIt));

p -> value = val;

if(!dest) // first item addition

{

p -> p_next = NULL;

dest = p;

}

else

{

pListIt find = dest;

pListIt at = NULL;

// first find the first greater number, insert before

while(find && find->value <= val)

{

if( find->value == val) // do not add a duplicate

{

free(p);

return false;

}

at = find;

find = find->p_next;

}

// insert at at

if (at) // insert at a valid point

{

p->p_next = at->p_next;

at->p_next = p;

}

else // insert at the start

{

p->p_next = dest;

dest = p;

}

}

return true;

}

//************************************

// Method: print -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:12

// Purpose: Print the content of the relevant arrays

//************************************

void print(Vertex**& neighborMatrix ,const int&n, Node*& list)

{

printf("\n The capacity \n");

int i =0, j =0;

for(i = 1 ; i <= n; ++i, printf("\n"))

for( j = 1; j <= n; ++j)

printf(" %d ", neighborMatrix[j].capicity);

printf("\n\n The neighbors: \n");

pListIt p;

for( i =1; i<=n; ++i, printf("\n"))

{

printf("%d ~ %d -> ", i, list.vertexNr);

p = list.neighboors;

while(p)

{

printf(" %d ", p->value);

p = p->p_next;

}

}

printf("\n\n");

}

//************************************

// Method: Ford_Fulkelson -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// int source

// int terminal

// const int & n

// Returns: int

// Created by: Gábor Bernát -> 18:1:2009 11:13

// Purpose: The algorithm

//************************************

int Ford_Fulkelson(Vertex**& neighborMatrix, Node*& list, int source, int terminal, const int& n)

{

int flowOverall =0 ;

int min = 0;

do

{

min = INFINITY;

searchAugmentation(neighborMatrix, list, source,terminal,min,n);

flowOverall += min;

}while(min);

return flowOverall;

}

//************************************

// Method: searchAugmentation -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// int source

// int terminal

// int & min

// const int & n

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:14

// Purpose: Find the shortest road next

//************************************

void searchAugmentation( Vertex**& neighborMatrix, Node*& list, int source, int terminal, int& min, const int& n)

{

int* ancient;

int* color;

pListIt Q;

ancient = (int*) malloc ((n+1)*sizeof(int));

color = (int*) malloc ((n+1)*sizeof(int));

memset(ancient, 0, (n+1)*sizeof(int) );

memset(color , WHITE , (n+1)*sizeof(int) );

color[source] = GRAY;

ancient[source] = 0;

Q = NULL;

// put source into the queue

Q = (pListIt) malloc ( sizeof( ListIt));

Q->value = source;

Q->p_next = NULL;

int u = 0, v = 0;

pListIt at;

pListIt endQSe;

while(Q)

{

u = Q->value;

for( at = list.neighboors; at; at = at->p_next)

{

v = at->value;

if (color[v] == WHITE)

{

if (neighborMatrix[v].capicity != -1 && neighborMatrix[v].flowValue < neighborMatrix[v].capicity )

{

color[v] = GRAY;

ancient[v] = u;

if (v == terminal)

{

#ifdef VERBOSE

printf("\n-Negative: ");

printImprovement(ancient,terminal);

#endif

improvement(neighborMatrix, terminal,ancient, min);

#ifdef VERBOSE

printf(" ----> with %d", min);

#endif

return; // stop the search as we found it

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

else

{

if (neighborMatrix[v].capicity != -1 && neighborMatrix[v].flowValue > 0)

{

color[v] = GRAY;

ancient[v] = -u;

if (v ==terminal)

{

#ifdef VERBOSE

printf("\n +Positive: ");

printImprovement(ancient,terminal);

#endif

improvement(neighborMatrix, terminal,ancient, min);

#ifdef VERBOSE

printf(" ----> with %d", min);

#endif

free(ancient);

free(color);

return;

}

// find the end of Q

for(endQSe = Q; endQSe->p_next;endQSe = endQSe->p_next);

// put v into the queue

endQSe->p_next = (pListIt) malloc ( sizeof( ListIt));

endQSe->p_next->value = v;

endQSe->p_next->p_next = NULL;

}

}

}

}

//delete first item

endQSe = Q;

Q = Q->p_next;

free(endQSe);

color = BLACK;

}

min = 0; // no improvement found

free(ancient);

free(color);

}

//************************************

// Method: improvement -> public access

// Parameter\s:

// Vertex * * & adiacentMatrix

// int currentVertex

// int * & ancient

// int & minimal

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:15

// Purpose: Make the improvement

//************************************

void improvement(Vertex**& adiacentMatrix, int currentVertex, int*& ancient, int& minimal )

{

int vertexAt = 0;

if (ancient[currentVertex] < 0)

{

vertexAt = -ancient[currentVertex];

if (minimal > adiacentMatrix[currentVertex][vertexAt].flowValue)

{

minimal = adiacentMatrix[currentVertex][vertexAt].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[currentVertex][vertexAt].flowValue -= minimal;

}

else

{

if (ancient[currentVertex] > 0 )

{

vertexAt = ancient[currentVertex];

if (minimal > adiacentMatrix[vertexAt][currentVertex].capicity

- adiacentMatrix[vertexAt][currentVertex].flowValue )

{

minimal = adiacentMatrix[vertexAt][currentVertex].capicity

- adiacentMatrix[vertexAt][currentVertex].flowValue;

}

improvement(adiacentMatrix, vertexAt, ancient, minimal);

adiacentMatrix[vertexAt][currentVertex].flowValue += minimal;

}

}

}

//************************************

// Method: printImprovement -> public access

// Parameter\s:

// const int * const & ancient

// const int vertex

// Returns: void

// Created by: Gábor Bernát -> 18:1:2009 11:15

// Purpose: Self explanatory

//************************************

void printImprovement(const int*const & ancient, const int vertex)

{

if (vertex)

{

if (vertex<0)

{

printImprovement(ancient, ancient[-vertex]);

printf(" %d ", -vertex); // the last item

}

else

{

printImprovement(ancient, ancient[vertex]);

printf(" %d ", vertex); // the last item

}

}

}

//************************************

// Method: kConnectedEdge -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// Node * & list

// const int & n

// Returns: int

// Created by: Gábor Bernát -> 21:1:2009 0:08

// Purpose: Calculate how many edges can be deleted in a fashion that we maintain the connectivity

//************************************

int kConnectedEdge(Vertex**& neighborMatrix, Node*& list, const int& n)

{

int i = 0, j = 0, curKCon = 0;

int k = INFINITY;

for( i=1; i <= n-1; ++i)

for( j=i+1; j<= n; ++j)

{

int a =0, b = 0;

for (a = 1; a <= n; ++a)

for (b = 1; b <= n ; ++b)

{

neighborMatrix[a].flowValue = 0;

}

curKCon = Ford_Fulkelson(neighborMatrix, list, i , j, n);

if (curKCon < k)

{

k = curKCon;

}

}

return k;

}

//************************************

// Method: readConnectEdge -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: void

// Created by: Gábor Bernát -> 21:1:2009 0:16

// Purpose:

//************************************

void readConnectEdge(Vertex**& neighborMatrix, int&n, Node*& list )

{

FILE* f;

freopen_s(&f,"Ford.in", "r", stdin);

freopen_s(&f,"Ford.out", "w", stdout);

scanf_s("%d", &n);

// now create vertex neighborMatrixix and list

// we will creat a little larger so we can read in indexing from 1

neighborMatrix = (Vertex**) calloc(n+1, sizeof(Vertex*));

int i =0; // local variable we are going to use

for( i = 1; i <= n; ++i)

{

neighborMatrix = (Vertex*) calloc(n+1, sizeof(Vertex));

}

int j =0;

for( i =1; i <= n; ++i)

for( j =1; j <= n; ++j)

neighborMatrix[j].capicity = -1;

// we will also create the list

list = (Node*) calloc(n+1, sizeof(Node)); // this will also initialize all the variables with 0

// Now read from the file and build up the structure of the Vertex neighborMatrixix and the list

int from,to; // a couple of local variables used for data input

while( !feof(stdin)) // while we have for what to read

{

scanf_s("%d%d", &from, &to);

// we will increase now the capacity of both the input and output

neighborMatrix[from][to].capicity = 1;

#ifdef DIRECTED

neighborMatrix[to][from].capicity = 1;

#endif

// the flowValue counterpart will be set for all the values to 0 by the calloc

if(add(list[to].neighboors, from))

list[to].vertexNr++; // increase with one -> incoming edges

if(add(list[from].neighboors, to))

list[from].vertexNr++; // increase with one -> outgoing edges

}

}

//************************************

// Method: extractByPointGraph -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Vertex * * & toNeighborMatrix

// Node * & toList

// Returns: void

// Created by: Gábor Bernát -> 21:1:2009 1:27

// Purpose: Build up the extracted data sets

//************************************

void extractByPointGraph( Vertex**& neighborMatrix , int&n,Vertex**& toNeighborMatrix , Node*& toList )

{

int i =0;

int j =0;

// First allocate space for the items

toNeighborMatrix = (Vertex**) calloc(2*n+1, sizeof(Vertex*));

for( i = 1; i <= 2*n; ++i)

{

toNeighborMatrix = (Vertex*) calloc(2*n+1, sizeof(Vertex));

}

for( i =1; i <= 2*n; ++i)

for( j =1; j <= 2*n; ++j)

toNeighborMatrix[j].capicity = -1;

// we will also create the list

toList = (Node*) calloc(2*n+1, sizeof(Node)); // this will also initialize all the variables with 0

// fill the matrix and the list

for (i = 1; i <= n ; ++i) // divide

{

toNeighborMatrix[n+i].capicity = 1;

if( add(toList[n+i].neighboors, i ) )

{

++toList[n+i].vertexNr;

}

if( add(toList.neighboors, n+i ) )

{

++toList.vertexNr;

}

}

for (i = 1; i <= n ; ++i) // reconnect edges

for (j = 1; j <= n; ++j)

{

if (neighborMatrix[j].capicity != -1)

{

toNeighborMatrix[n+i][j].capicity = 1;

if( add(toList[n+i].neighboors, j ) )

{

++toList[n+i].vertexNr;

}

if( add(toList[j].neighboors, n+i ) )

{

++toList[j].vertexNr;

}

}

}

}

//************************************

// Method: kConnectedVertex -> public access

// Parameter\s:

// Vertex * * & neighborMatrix

// int & n

// Node * & list

// Returns: int

// Created by: Gábor Bernát -> 21:1:2009 1:42

// Purpose:

//************************************

int kConnectedVertex( Vertex**& neighborMatrix , int&n )

{

Vertex** extendedNeighborMatrix = NULL;

Node* extendedList = NULL;

extractByPointGraph(neighborMatrix, n, extendedNeighborMatrix, extendedList);

//print(extendedNeighborMatrix, 2*n, extendedList);

int k = INFINITY, curKCon = 0;

int i= 0, j = 0;

for( i=1; i <= n-1; ++i)

for( j=i+1; j<= n; ++j)

{

int a =0, b = 0;

for (a = 1; a <= 2*n; ++a)

for (b = 1; b <= 2*n ; ++b)

{

extendedNeighborMatrix[a].flowValue = 0;

}

extendedNeighborMatrix[n+i].capicity = INFINITY;

curKCon = Ford_Fulkelson(extendedNeighborMatrix, extendedList, i , j, 2*n);

extendedNeighborMatrix[n+i].capicity = 1;

if (curKCon < k)

{

k = curKCon;

}

}

return k;

}

#4

الموضوع ممتع وجميل

ولكنه متشابك أى المشاركات داخلة فى بعضها البعض:

أقترح عليك أضافة مشاركة واحدة فقط مع أضافة رابط لمصدرها ثم توضيح مبسط للمشكلة

هما يستطيع اﻻعضاء مساعدتك بكل سهولة

تحياتى العطرة والله ولى التوفيق

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#5

السلام عليكم

ساعيد طرح المشكلة

المطلوب هو تنفيد خوارزمية فورد لحساب اعلى جريان في الشبكة

IMPLEMENTATION CODE FOR

The Ford-Fulkerson algorithm to determine the maximum flow of the network

حاولت ابحث عن كود يشتغل فلم اجده كل واحد بيه اخطاء واول كود وضعته في المشاركة الاولى اعلاه ، به خطا واحد فقط وهو

too much global data defined in file

مادا يعني برسالة الخطا المدكورة وكيف يمكن تصحيحها

اما الكود الاخر فهو من الرابط التالي ، ما ان تفتحه حتى يظهر لك رابط تحمل ملف به كود البرنامج كاملا وعند تنفيده تظهر ثلاثة اخطاء لم اعرف كيف اصححها فارجو المساعدة .

http://pastebin.com/download.php?i=m6MaZ8SE

#6

وهدا رابط اخر وبه كود اخر لنفس البرنامج ( نفس الخوارزمية)

ولكن يحتوي على اربعة اخطاء فقط و المدخلات وناتج البرنامج موجود في الرابط التالي :

http://hauionline.com/archive/index.php/t-7371.html

ولايحتاج الامر الى فهم كافة تفاصيل الكود ولكن من لديه خبره في برنامج سي بلس بلس يمكنه تصحيح الاخطاء الموجوده

ارجو المساعدة قدر الامكان ولكم جزيل الشكر مسبقا

#7

الكود به بعد التعديل

تذكر ا المشاركة :http://www.hauionline.com/archive/index.php/t-7371.html

بها خطأ وان المشاركة اﻻصلية http://aduni.org/courses/algorithms/courseware/handouts/Reciation_09.html صحيحة فقط.

الكود بعد تحويلة الى سي++ :

- وحتى تتفادى عملية أنشاء ملف المدخلات قمنا بأضافة الداله void create_input_file()

الكود:

#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX_NODES 1000
#define oo 1000000000

int n; // number of nodes
int e; // number of edges
int capacity[MAX_NODES][MAX_NODES]; // capacity matrix
int flow[MAX_NODES][MAX_NODES]; // flow matrix
int color[MAX_NODES]; // needed for breadth-first search
int pred[MAX_NODES]; // array to store augmenting path

int min(int x, int y)
{
    return x < y ? x : y; // returns minimum of x and y
}
//A Queue for Breadth - First Search

int head, tail;
int q[MAX_NODES + 2];

void enqueue(int x)
{
    q[tail] = x;
    tail++;
    color[x] = GRAY;
}

int dequeue()
{
    int x = q[head];
    head++;
    color[x] = BLACK;
    return x;
}
//Breadth - First Search for an augmenting path

int bfs(int start, int target)
{
    int u, v;
    for (u = 0; u < n; u++)
    {
        color = WHITE;
    }
    head = tail = 0;
    enqueue(start);
    pred[start] = -1;
    while (head != tail)
    {
        u = dequeue();
        // Search all adjacent white nodes v. If the capacity
        // from u to v in the residual network is positive,
        // enqueue v.
        for (v = 0; v < n; v++)
        {
            if (color[v] == WHITE && capacity[v] - flow[v] > 0)
            {
                enqueue(v);
                pred[v] = u;
            }
        }
    }
    // If the color of the target node is black now,
    // it means that we reached it.
    return color[target] == BLACK;
}

//Ford - Fulkerson Algorithm

int max_flow(int source, int sink)
{
    int i, j, u;
    // Initialize empty flow.
    int max_flow = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            flow[j] = 0;
        }
    }
    // While there exists an augmenting path,
    // increment the flow along this path.
    while (bfs(source, sink))
    {
        // Determine the amount by which we can increment the flow.
        int increment = oo;
        for (u = n - 1; pred >= 0; u = pred)
        {
            increment = min(increment, capacity[pred] - flow[pred]);
        }
        // Now increment the flow.
        for (u = n - 1; pred >= 0; u = pred)
        {
            flow[pred] += increment;
            flow[pred] -= increment;
        }
        max_flow += increment;
    }
    // No augmenting path anymore. We are done.
    return max_flow;
}

//Reading the input file and the main program

void read_input_file()
{
    int a, b, c, i, j;
    ifstream inputfile("mf.in");
    // read number of nodes and edges
    inputfile >> n >> e;
    // initialize empty capacity matrix
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            capacity[j] = 0;
        }
    }
    // read edge capacities
    for (i = 0; i < e; i++)
    {
        inputfile >> a >> b >> c;
        capacity[a] = c;
    }
    // fclose(input);
}

void create_input_file()
{
    ofstream outfile("mf.in");
    outfile << "6 10" << endl
            << "0 1 16" << endl
            << "0 2 13" << endl
            << "1 2 10" << endl
            << "2 1 4" << endl
            << "3 2 9" << endl
            << "1 3 12" << endl
            << "2 4 14" << endl
            << "4 3 7" << endl
            << "3 5 20" << endl
            << "4 5 4 " << endl;
}

int main()
{
    create_input_file(); // to simplify creating input file ... 
    read_input_file();
    cout << max_flow(0, n - 1) << endl;
    return 0;
}

المخرجات:

23
Press [Enter] to close the terminal ...

هذا فقط للأعضاء الجدد

تقبلو مرورى والله ولى التوفيق

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#8

AudaNix الاخ صاحب المشاركة

شكرا لك كثيرا على الاجابة وعلى حسن التواصل

لقد حاولت تنفيذ الكود الذي كتبته ، ولكن ظهرت لي ثلاثة رسائل خطا وهي كالتالي :

Cpp 14 :Array size too large

Cpp. 15 : Array size too large

Cpp 15: too much global data defined in file

ارجوان توضح لي كيف حصلت على المخرجات واي برنامج تستعملة علما باني استخدم برنامج

Turo c++

وانا مازلت احتاج المساعدة لكي احصل على النتائج فارجو التواصل

#9

أختى الفاضلة:

اقتباس
Cpp 14 :Array size too large

Cpp. 15 : Array size too large

Cpp 15: too much global data defined in file

ارجوان توضح لي كيف حصلت على المخرجات واي برنامج تستعملة علما باني استخدم برنامج

Turo c++

هذا بسبب ان المترجم تربو سي++ لم يستوعب حجم بيانات 1000000000 ﻻنة قديم جدا

انصحك بشدة باﻻنتقال الى بيئة برمجة أكثر قوة مثل التى كتبت بها الكود netbeans 7

حملى النسخة المتوافقة مع ويندوزمن الموقع المخصصة للــ سي و سي++

واستمتعى بكود خالى من اﻻخطاء ان شاء الله

تقبلى مرورى والله ولى التوفيق

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

مواضيع مشابهة