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

تحويل كود من لغة الى اخرى

مغلق
بدأه bachirk في 12 أغسطس 2007 · 11 رد · 1,206 مشاهدة · في لغة Delphi
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لدي كود function معمول بالدالفي اريد ان احوله الى c# او c++ او vb او c

الكود هو حل خورزمية مطروحة في مسابقة topcoder فئة marathon math

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

و سوف اكون شاكرا له

مع العلم اني حاولت تحويل الكود ببرامج مخصصة لذلك لكن كان هناك دائما مشكل

و المسابقة لا تقبل اكواد باسكال

function play(board:tab;words:array of string):longint;
label 10,20;
var lett:array[0..10,0..10] of char;
	w,i,j,n,last,h1,h,hv1,k,scor,scormax:longint;
	resultnbr,nbrw,nbri,nbrj,nbrn:longint;
	hv:array[0..10,0..10]of record h,v,hs,vs:longint; end;
	wordlist:array[0..100] of record enb,i,j,hv,scor:longint end;
	resultt:array[0..9999] of string;
	resultf:array of string;
	done:boolean;
	lettscor:array['A'..'Z'] of longint;
	c:char;
function wordscor(s:string;i,j,hv:longint):longint;
var i1,wordscor1:longint;
begin
wordscor1:=0;
if hv=1 then
begin
for i1:=1 to length(s) do
if (board[i,j+i1-1]<>'D')and(board[i,j+i1-1]<>'T') then
wordscor1:=wordscor1+lettscor[s[i1]]*strtoint(board[i,j+i1-1])
else
wordscor1:=wordscor1+lettscor[s[i1]];
for i1:=1 to length(s) do
if board[i,j+i1-1]='D' then
wordscor1:=2*wordscor1
else
if board[i,j+i1-1]='T' then
wordscor1:=3*wordscor1
end
else
begin
for i1:=1 to length(s) do
if (board[i+i1-1,j]<>'D')and(board[i+i1-1,j]<>'T') then
wordscor1:=wordscor1+lettscor[s[i1]]*strtoint(board[i+i1-1,j])
else
wordscor1:=wordscor1+lettscor[s[i1]];
for i1:=1 to length(s) do
if board[i+i1-1,j]='D' then
wordscor1:=2*wordscor1
else
if board[i+i1-1,j]='T' then
wordscor1:=3*wordscor1
end;
wordscor:=wordscor1;
end;
function unadd(s:string;i,j,hv1:longint):boolean;
var h:longint;
begin
if hv1=1 then
begin
for h:=1 to length(s) do
begin
hv[i,j+h-1].hs:=0;
if hv[i,j+h-1].vs=0 then
lett[i,j+h-1]:=' ';
end;
end
else
begin
for h:=1 to length(s) do
begin
hv[i+h-1,j].vs:=0;
if hv[i+h-1,j].hs=0 then
lett[i+h-1,j]:=' ';
end;
end;
end;
function add(s:string;i,j,hv1:longint):boolean;
var h:longint;
   done:boolean;
begin
done:=false;
add:=false;
if hv1=1 then
begin
if length(s)<=hv[i,j].h then
begin
done:=true;
for h:=1 to length(s) do
if (hv[i,j+h-1].hs=1)or((lett[i,j+h-1]<>' ')and(lett[i,j+h-1]<>s[h])) then
done:=false;
if done then
for h:=1 to length(s) do
begin
lett[i,j+h-1]:=s[h];
hv[i,j+h-1].hs:=1;
end;
end;
end
else
begin
if length(s)<=hv[i,j].v then
begin
done:=true;
for h:=1 to length(s) do
if (hv[i+h-1,j].vs=1)or((lett[i+h-1,j]<>' ')and(lett[i+h-1,j]<>s[h])) then
done:=false;
if done then
for h:=1 to length(s) do
begin
lett[i+h-1,j]:=s[h];
hv[i+h-1,j].vs:=1;
end;
end;
end;
add:=done;
end;
begin
for c:='A' to 'Z' do lettscor[c]:=1;
lettscor['F']:=4; lettscor['H']:=4; lettscor['V']:=4; lettscor['W']:=4;
lettscor['Y']:=4;
lettscor['B']:=3; lettscor['C']:=3; lettscor['M']:=3; lettscor['P']:=3;
lettscor['D']:=2; lettscor['G']:=2;
lettscor['J']:=8; lettscor['X']:=8;
lettscor['Q']:=10; lettscor['Z']:=10;
lettscor['K']:=5;
//5555555555555
nbrw:=length(words);
nbri:=length(board);
nbrj:=length(board[0]);
nbrn:=(nbri*nbrj)-1;
//555555555555
for i:=0 to nbri-1 do
for j:=0 to nbrj-1 do
if board[i,j]<>'#'  then
begin
hv[i,j].h:=0;
hv[i,j].v:=0;
n:=0;
repeat
n:=n+1;
until ((j+n)>(nbrj-1))or(board[i,j+n]='#');
hv[i,j].h:=n;
n:=0;
repeat
n:=n+1;
until ((i+n)>(nbri-1))or(board[i+n,j]='#');
hv[i,j].v:=n;
hv[i,j].hs:=0;
hv[i,j].vs:=0;
end
else
begin
hv[i,j].h:=0;
hv[i,j].v:=0;
hv[i,j].hs:=0;
hv[i,j].vs:=0;
end;
//888888888888888888888888
for i:=0 to nbri-1 do
for j:=0 to nbrj-1 do
lett[i,j]:=' ';
for i:=0 to nbrw-1 do
begin
wordlist.enb:=0;
wordlist.j:=0;
wordlist.i:=0;
wordlist.hv:=0;
end;

scor:=0;
scormax:=0;
h:=0;
i:=0;
repeat
repeat
//**
if wordlist.enb=1 then
begin
scor:=scor-wordscor(words,wordlist.i,wordlist.j,wordlist.hv);
unadd(words,wordlist.i,wordlist.j,wordlist.hv);
n:=wordlist.i*nbrj+wordlist.j;
hv1:=wordlist.hv;
wordlist.enb:=0;
wordlist.i:=0;
wordlist.j:=0;
wordlist.hv:=0;
end
else
begin
n:=-1;
done:=true;
for h1:=i-1 downto 0 do
if (wordlist[h1].enb=1)and(words=words[h1]) then
done:=false;
if  not done then goto 20;
end;
//**
if hv1=1 then
begin
done:=add(words,n div nbrj,n mod nbrj,2);
if done then
begin
wordlist.enb:=1;
wordlist.i:=n div nbrj;
wordlist.j:=n mod nbrj;
wordlist.hv:=2;
scor:=scor+wordscor(words,wordlist.i,wordlist.j,wordlist.hv);
goto 20;
end;
end;
n:=n+1;
while (n<(nbrn)) do
begin
done:=add(words,n div nbrj,n mod nbrj,1);
if done then
begin
wordlist.enb:=1;
wordlist.i:=n div nbrj;
wordlist.j:=n mod nbrj;
wordlist.hv:=1;
scor:=scor+wordscor(words,wordlist.i,wordlist.j,wordlist.hv);
goto 20;
end;
done:=add(words,n div nbrj,n mod nbrj,2);
if done then
begin
wordlist.enb:=1;
wordlist.i:=n div nbrj;
wordlist.j:=n mod nbrj;
wordlist.hv:=2;
scor:=scor+wordscor(words,wordlist.i,wordlist.j,wordlist.hv);
goto 20;
end;
n:=n+1;
end;
20:
i:=i+1;
until  i>(nbrw-1);
k:=nbrw;
repeat
k:=k-1;
until (wordlist[k].enb=1)or(k=-1);
i:=k;
if scor>scormax then
begin
scormax:=scor;
resultnbr:=0;
for k:=0 to nbrw-1 do
if wordlist[k].enb=1 then
begin
resultt[resultnbr]:='';
if wordlist[k].hv=1 then
resultt[resultnbr]:=resultt[resultnbr]+'H '
else
resultt[resultnbr]:=resultt[resultnbr]+'V ';
resultt[resultnbr]:=resultt[resultnbr]+inttostr(k)+' '+inttostr(wordlist[k].j)+' '+inttostr(wordlist[k].i);
resultnbr:=resultnbr+1;
end;
end;
h:=h+1;
until h=1000;
setlength(resultf,resultnbr);
for i:=0 to resultnbr-1 do
resultf:=resultt;
play:=scormax;
end;
#2
اقتباس
و المسابقة لا تقبل اكواد باسكال

كيف هذا ؟؟؟

هل الغى ايوب استعمال Delphi في المسابقة ؟

d4baa0.gif
#3

الدالة في الخورزمية يجب ان يكون مخرجها جدول ديناميكي array of string

2-ارجوا ان يوضع في مخرج الدالة الجدول resultf

3-في مدخلات الدالة المتغير board يجب ان يصرح به كجدول ديناميكي من بعديين array of array of string

تم تعديل هذه المشاركة بواسطة bachirk في 12 أغسطس 2007 في 15:18

#4

لا اقصد مسابقة marathon math التي تنظمها google

#5

نص المسألة

Problem Statement

Scruffle is a single player word game, played on a rectangular board. The goal of the game is to score as many point as possible by placing words on the board. The board contains obstacles in some of the cells; no word may be placed to overlap with one of these obstacles. The player is given a list of available words; each word may be placed on the board only once. A word may be placed horizontally or vertically and must read from left to right or top to bottom. A word may be placed such that it overlaps with an already placed word, in which case the overlapping letters of the words must be the same. A word may not go off the edge of the board. When placing a word, at least one of its letters must not overlap with any previously placed word.

Each letter is worth a specific amount of points.
The letters A, E, I, L, N, O, R, S, T and U is worth 1 point.
The letters D and G are worth 2 points.
The letters B, C, M and P are worth 3 points.
The letters F, H, V, W and Y are worth 4 points.
The letter K is worth 5 points.
The letters J and X are worth 8 points.
The letters Q and Z are worth 10 points.

Each cell of the board can contain one of the following:
# : The cell contains an obstacle, no word may overlap with this cell.
0-9 : Letter multiplier. The score of the letter that is placed on this cell will be multiplied by the given number. Ex. If the cell contains a 5 and the player places a letter B on the cell, the score for that placement will be 5 * 3 = 15.
D : Double word multiplier. The score of the word placed over this cell will be multiplied by 2. The score of the letter placed on this cell will be just the letter points (Letter multiplier of 1.). If a word overlaps with more than one word multiplier, the word score will be cumulative. Ex. If the score of a word before applying the word multiplier is 12 and the word overlaps with 2 D’s, then the total score for the placement will be 12 * 2 * 2 = 48.
T : Triple word multiplier. The score of the word placed over this cell will be multiplied by 3. This multiplier works cumulatively with the double word multiplier.

The score for each word placement will be calculated independently from previously placed words. All letter and word multipliers that form part of the placement will be used in the calculation. Pseudo code for calculating the score of a word placement:
letterScore = 0
wordMultiplier = 1
for each letter in the word
	cell = cell where this letter will be placed
	if cell contains a D
		letterScore = letterScore + worth of letter
		wordMultiplier = wordMultiplier * 2
	else if cell contains a T
		letterScore = letterScore + worth of letter
		wordMultiplier = wordMultiplier * 3
	else
		letterScore = letterScore + worth of letter * letter multiplier of cell
	end 
score for placement = letterScore * wordMultiplier

You will play the game by writing a single method play. The play method will take a String[] that contains the definition of the board and a String[] that contains a list of all the available words. The method will be called only once. You must return a String[] that contains all your word placements. Each element contains a single placement. Words will be placed on the board in the same order as in your return. The format of a placement is the direction of the placement followed by the 0-based index of the word that must be placed, followed by the (x, y) 0-based position where the first letter of the word must be placed. The direction character must be a H for horizontal placement or a V for vertical placement. Ex. “H 10 5 3” indicates the horizontal placement of the word at index 10, and the placement starts at position (5, 3) of the board.

Your score for a test case will be the sum of all the scores for each placement. You will receive a score of 0 when you perform an invalid placement or when the method runs out of time. Your final score will be found by taking the sum over test cases of (your score)/(highest score).
Test case generation

All random values are computed uniformly and ranges are stated inclusively. The horizontal dimension X of the board will be chosen between 10 and 100. The vertical dimension Y of the board will be chosen between 10 and 100.

A fraction 0 <= B <= 0.2 of the cells are blocked with obstacles, a fraction 0 <= D <= 0.05 of the cells are doubles ('D'), and a fraction 0 <= T <= 0.02 of the cells are triples ('T'). All these cells are selected randomly, with a new random selection being made if a selected cell was already previously marked. The remaining cells are filled with numbers '0'-'9'.

The number of words W will be chosen between 10 and 10000. Words will then be randomly selected from the English dictionary. The same word may appear more than once in the list given to your method. See the notes section for a link to the words of our dictionary.

Definition
			Class:	Scruffle
Method:	play
Parameters:	String[], String[]
Returns:	String[]
Method signature:	String[] play(String[] board, String[] words)
(be sure your method is public)




Notes
-	There are 50 non-example tests.
-	The complete list of words can be downloaded from here. The words between length 1 and 8 were extracted.
-	Each word will only contain uppercase characters between A and Z.
-	Each word may be placed on the board only once.

Constraints
-	The memory limit is 1024MB.
-	The time limit is 30 seconds.

Examples
0)	
			5#17475928
9158971908
61662#6593
29#2909138
15950557T7
858912#029
098668#528
025121716#
9D31739229
##D683##74
Number of words=15
DOPAMINE
CUTISES
IMAGOS
COCOANUT
SOLECISM
GLOM
INBRED
DABSTERS
YARN
CRABBIER
HOPPLING
UNRIPPED
FUSIONS
DOPED
AGONY

The following placements results in a score of 802.
V 10 1 1 ( Placement score = 130 )

H 9 2 1 ( Placement score = 73 )

V 0 0 1 ( Placement score = 64 )

H 11 2 0 ( Placement score = 79 )

V 12 3 2 ( Placement score = 48 )

H 2 4 4 ( Placement score = 126 )

V 6 2 4 ( Placement score = 102 )

H 13 4 3 ( Placement score = 52 )

V 14 4 5 ( Placement score = 54 )

H 5 6 2 ( Placement score = 35 )

V 8 5 6 ( Placement score = 39 )


The resulting board looks like this:
.#UNRIPPED
DHCRABBIER
OO.F.#GLOM
PP#UDOPED.
APISIMAGOS
MLNIA.#...
IIBOGY#...
NNRNOA...#
EGESNR....
##D.YN##..
#6

حبذا يا أخي لو تضع الترجمة لنص المسألة لتعم الفائدة

و جزاك الله خيرا

#7

عليا اولا ان اجد حل لمشكلتي ثم سوف اضع شرح للمسالة ونناقش الحل

#8

للأسف اخي بشير لا اعرف طريقة مثالية لتحويل الكود لكن هناك برنامج Reflector الخاص بلغات الدوت نت و منها الدلفي دوت نت و يقوم بعرض الكود سورس بجميع لغات الدوت نت (vb.net,c#,j#,delphi.net) لا ادري اذ كنت استعملته ام لا لكن حاول و ان شاء الله ينجح و تنجح في المسابقات المقبلة رغم ان تحويل الكود سيفقده الكثير

على فكرة المسابقة ليست جوجل من تنظمها بل كل مرة تكون تحت رعاية شركة معينة

#9
//---------------------------------------------------------------------------
#define DIV(x, y)	int(floor(int(x) / int(y)))
#define MOD(x, y)	int(int(x) % int(y))
//---------------------------------------------------------------------------
struct hv_struct
{
  int h;
  int v;
  int hs;
  int vs;
};
//---------------------------------------------------------------------------
struct wordlist_struct
{
  int enb;
  int i;
  int j;
  int hv;
  int scor;
};
//---------------------------------------------------------------------------
hv_struct hv[11][11];
//---------------------------------------------------------------------------
char **board;
//---------------------------------------------------------------------------
map<char, int, less<char> > lettscor;
//---------------------------------------------------------------------------
char lett[11][11];
//---------------------------------------------------------------------------
int chartoint(char c)
{
  return int(c) - 48;
}
//---------------------------------------------------------------------------
int strtoint(char *s)
{
  int result = 0;
  for ( int i = 0; i < strlen(s); i++ )
  {
	result = result + chartoint(s) * pow(10, strlen(s) - 1 - i);
  }
  return result;
}
//---------------------------------------------------------------------------
char *digittostr(int i)
{
  char *s = "0";
  s[0] = (char) (i + 48);
  return s;
}
//---------------------------------------------------------------------------
char *inttostr(int i)
{
  char *result = "";
  char *s;
  while ( i > 10 )
  {
	s = digittostr(MOD(i, 10));
	result = strcat(result, s);
	i = DIV(i, 10);
  }
  s = digittostr(MOD(i, 10));
  result = strcat(result, s);
  return strrev(result);
}
//---------------------------------------------------------------------------
int wordscor(char *s, int i, int j, int hv)
{
  int wordscor1 = 0;
  if ( hv == 1 )
  {							
	for ( int i1 = 1; i1 <= strlen(s); i1++ )
	{
	  if ( (board[j + i1 - 1] != 'D') && (board[j + i1 -1] != 'T') )
	  {
		wordscor1 = wordscor1 + lettscor[s[i1]] * chartoint(board[j + i1 - 1]);
	  }
	  else
	  {
		wordscor1 += lettscor[s[i1]];
	  }
	}
	for ( int i1 = 1; i1 <= strlen(s); i1++ )
	{
	  if ( board[j + i1 - 1] == 'D' )
	  {
		wordscor1 *= 2;
	  }
	  else
	  {
		if ( board[j + i1 - 1] == 'T' )
		{
		  wordscor1 *= 3;
		}
	  }
	}
  }
  else
  {
	for ( int i1 = 1; i1 <= strlen(s); i1++ )
	{
	  if ( (board[i + i1 - 1][j] != 'D') && (board[i + i1 - 1][j] != 'T') )
	  {
		wordscor1 = wordscor1 + lettscor[s[i1]] * chartoint(board[i + i1 - 1][j]);
	  }
	  else
	  {
		wordscor1 += lettscor[s[i1]];
	  }
	}
	for ( int i1 = 1; i1 <= strlen(s); i1++ )
	{
	  if ( board[i + i1 - 1][j] == 'D' )
	  {
		wordscor1 *= 2;
	  }
	  else if ( board[i + i1 - 1][j] == 'T' )
	  {
		wordscor1 *= 3;
	  }
	}
  }
  return wordscor1;
}
//---------------------------------------------------------------------------
bool unadd(char *s, int i, int j, int hv1)
{
  if ( hv1 == 1 )
  {
	for ( int h = 1; h <= strlen(s); h++ )
	{
	  hv[j + h - 1].hs = 0;
	  if ( hv[j + h - 1].vs == 0 )
	  {
		lett[j + h - 1] = ' ';
	  }
	}
  }
  else
  {
	for ( int h = 1; h <= strlen(s); h++ )
	{
	  hv[i + h - 1][j].vs = 0;
	  if ( hv[i + h - 1][j].hs == 0 )
	  {
		lett[i + h - 1][j] = ' ';
	  }
	}
  }
}
//---------------------------------------------------------------------------
bool add(char *s, int i, int j, int hv1)
{
  bool done = false;
  if ( hv1 == 1 )
  {
	if ( strlen(s) <= hv[j].h )
	{
	  done = true;
	  for ( int h = 1; h <= strlen(s); h++ )
	  {
		if ( (hv[j + h - 1].hs == 1) || ((lett[j + h - 1] != ' ') && (lett[j + h - 1] != s[h])) )
		{
		  done = false;
		}
	  }
	  if ( done )
	  {
		for ( int h = 1; h <= strlen(s); h++ )
		{
		  lett[j + h - 1] = s[h];
		  hv[j + h - 1].hs = 1;
		}
	  }
	}
  }
  else
  {
	if ( strlen(s) <= hv[j].v )
	{
	  done = true;
	  for ( int h = 1; h <= strlen(s); h++ )
	  {
		if ( (hv[i + h - 1][j].vs == 1) || ((lett[i + h - 1][j] != ' ') && (lett[i + h - 1][j] != s[h])) )
		{
		  done = false;
		}
	  }
	  if ( done )
	  {
		for ( int h = 1; h <= strlen(s); h++ )
		{
		  lett[i + h - 1][j] = s[h];
		  hv[i + h - 1][j].vs = 1;
		}
	  }
	}
  }
  return done;
}
//---------------------------------------------------------------------------
int play(char **words)
{
  wordlist_struct wordlist[101];

  int n;

  for ( char c = 'A'; c <= 'Z'; c++ )
  {
	lettscor[c] = 1;
  }
  lettscor['F'] = 4;
  lettscor['H'] = 4;
  lettscor['V'] = 4;
  lettscor['W'] = 4;
  lettscor['Y'] = 4;
  lettscor['B'] = 3;
  lettscor['C'] = 3;
  lettscor['M'] = 3;
  lettscor['P'] = 3;
  lettscor['D'] = 2;
  lettscor['G'] = 2;
  lettscor['J'] = 8;
  lettscor['X'] = 8;
  lettscor['Q'] = 10;
  lettscor['Z'] = 10;
  lettscor['K'] = 5;

  int nbrw = strlen(*words);
  int nbri = strlen(*board);
  int nbrj = strlen(board[0]);
  int nbrn = (nbri * nbrj) - 1;

  for ( int i = 0; i < nbri; i++ )
  {
	for ( int j = 0; j < nbrj; j++ )
	{
	  if ( board[j] != '#' )
	  {
		hv[j].h = 0;
		hv[j].v = 0;
		n = 0;
		do
		{
		  n++;
		} while ( ((j + n) > (nbrj - 1)) || (board[j + n] == '#') );
		hv[j].h = n;
		n = 0;
		do
		{
		  n++;
		} while ( ((i + n) > (nbri - 1)) || (board[i + n][j] == '#') );
		hv[j].v  = n;
		hv[j].hs = 0;
		hv[j].vs = 0;
	  }
	  else
	  {
		hv[j].h  = 0;
		hv[j].v  = 0;
		hv[j].hs = 0;
		hv[j].vs = 0;
	  }
	}
  }
  for ( int i = 0; i< nbri; i++ )
  {
	for ( int j = 0; j < nbrj; j++ )
	{
	  lett[j] = ' ';
	}
  }
  for ( int i = 0; i < nbrw; i++ )
  {
	wordlist.enb = 0;
	wordlist.j   = 0;
	wordlist.i   = 0;
	wordlist.hv  = 0;
  }

  bool done;
  int scor = 0;
  int scormax = 0;
  int h = 0;
  int i = 0;
  int hv1;
  int k;
  int resultnbr;
  char *resultt[10000];

  do
  {
	do
	{
	  if ( wordlist.enb = 1 )
	  {
		scor = scor - wordscor(words, wordlist.i, wordlist.j, wordlist.hv);
		unadd(words,wordlist.i,wordlist.j,wordlist.hv);
		n = wordlist.i * nbrj + wordlist.j;
		hv1 = wordlist.hv;
		wordlist.enb = 0;
		wordlist.i   = 0;
		wordlist.j   = 0;
		wordlist.hv  = 0;
	  }
	  else
	  {
		n = -1;
		done = true;
		for ( int h1 = i-1; h1 >= 0; h1-- )
		{
		  if ( (wordlist[h1].enb == 1) && (words == words[h1]) )
		  {
			done = false;
		  }
		}
		if ( !done )
		{
		  i++;
		  continue;
		}
	  }

	  if ( hv1 == 1 )
	  {
		done = add(words, DIV(n, nbrj), MOD(n, nbrj), 2);
		if ( done )
		{
		  wordlist.enb =1;
		  wordlist.i   = DIV(n, nbrj);
		  wordlist.j   = MOD(n, nbrj);
		  wordlist.hv  = 2;
		  scor += wordscor(words, wordlist.i, wordlist.j, wordlist.hv);
		  i++;
		  continue;
		}
	  }
	  n++;
	  while ( n < nbrn )
	  {
		done = add(words, DIV(n, nbrj), MOD(n, nbrj), 1);
		if ( done )
		{
		  wordlist.enb = 1;
		  wordlist.i   = DIV(n, nbrj);
		  wordlist.j   = MOD(n, nbrj);
		  wordlist.hv  = 1;
		  scor += wordscor(words, wordlist.i, wordlist.j, wordlist.hv);
		  break;
		}
		done = add(words, DIV(n, nbrj), MOD(n, nbrj), 2);
		if ( done )
		{
		  wordlist.enb =1;
		  wordlist.i   = DIV(n, nbrj);
		  wordlist.j   = MOD(n, nbrj);
		  wordlist.hv  =2;
		  scor += wordscor(words, wordlist.i, wordlist.j, wordlist.hv);
		  i++;
		  break;
		}
		n++;
	  }
	  i++;
	} while ( i > nbrw - 1 );
	k = nbrw;
	do
	{
	  k--;
	} while ( (wordlist[k].enb == 1) || (k == -1) );
	i = k;
	if ( scor > scormax )
	{
	  scormax = scor;
	  resultnbr = 0;
	  for ( k = 0; k < nbrw; k++ )
	  {
		if ( wordlist[k].enb=1 )
		{
		  resultt[resultnbr] = "";
		  if ( wordlist[k].hv == 1 )
		  {
			resultt[resultnbr] = strcat(resultt[resultnbr], "H ");
		  }
		  else
		  {
			resultt[resultnbr] = strcat(resultt[resultnbr], "V ");
		  }
		  resultt[resultnbr] = strcat(resultt[resultnbr], inttostr(k));
		  resultt[resultnbr] = strcat(resultt[resultnbr], " ");
		  resultt[resultnbr] = strcat(resultt[resultnbr], inttostr(wordlist[k].j));
		  resultt[resultnbr] = strcat(resultt[resultnbr], " ");
		  resultt[resultnbr] = strcat(resultt[resultnbr], inttostr(wordlist[k].i));
		  resultnbr++;
		}
	  }
	}
	h++;
  } while ( h == 1000 );

  return scormax;
}
//---------------------------------------------------------------------------

هذه نسخة محولة إلى Standard CPlusPlus مع تعديل بعض المتحولات إلى متحولات عامة

قمت بعملية التحويل دون النظر إلى مهمة التابع, ليس لدي إلا القليل من الوقت, ربما لاحقا

ولكن بالنسبة للكود الأساسي فإنه يستحق جائزة عدم التنظيم: لا يوجد تنسيق, متحولات بأسماء غير مفيدة, ...

#10

لا تنسى تضمين الكود التالي في البداية من أجل ربط المكتبات اللازمة:

//---------------------------------------------------------------------------
#include <math.h>
#include <string.h>
#include <map.h>
//---------------------------------------------------------------------------
#11

شكرا جزيلا لكن مهلة ارسال الحل انتهت من ساعتين للاسف

اين كنت قبل ايام

بالنسبة لتنظيم الكود انا عندما اراه اراه شديد الوضوح لاني اعرف ما فائدة

اي كلمة فيه او اي جملة او اي رقم

جزاك الله خيرا

#12
bachirk كتب:
بالنسبة لتنظيم الكود انا عندما اراه اراه شديد الوضوح لاني اعرف ما فائدة

وهل ستراه بنفس الوضوح بعد سنتين ؟

التنظيم مهم جدا و استثمار طويل المدى

d4baa0.gif

هذا الموضوع مغلق.

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…