......
........
//int selected[50]={0};
.......
......
......
{
for(int i=0; i<24; i++){
arr[row][i]=rand()%2;
cout<<arr[row][i];
}
.............
............
................
..............
cout<<"count: "<<count<<endl;
int fit=(term1-1)*(term1-1)+(term2-3)*(term2-3)+(term3-13)*(term3-13);
//cout<<term1<<" "<<term2<<" "<<term3<<" "<<fit<<"\n";
these some pieces of my code... I do not know how to convert to C.especialy I could not understand //these slash:)
I do not have enough time last two days
help me!!!
from C++ to Chow to convert this code
Page 1 of 1
3 Replies - 1386 Views - Last Post: 22 December 2005 - 04:54 PM
Replies To: from C++ to C
#2
Re: from C++ to C
Posted 22 December 2005 - 08:14 AM
The double slashes indicate a single line comment. If you see them on a line, that means everything following the slashes on that line is commented out. As for conversion to C, very little needs to be changed. Making the assumption that the arrays contains integers:
and
This makes the assumption that all variables are integers. You can modify based on variable type.
int i;
for(i=0; i<24; i++){
arr[row][i]=rand()%2;
printf("%d",arr[row][i]);
}
and
int fit;
printf("count: %d\n",count);
fit=(term1-1)*(term1-1)+(term2-3)*(term2-3)+(term3-13)*(term3-13);
/*printf("%d %d %d\n",term1,term2,term3);*/
This makes the assumption that all variables are integers. You can modify based on variable type.
#3
Re: from C++ to C
Posted 22 December 2005 - 04:08 PM
I have to ask this function definition....
I could not understand where it is used (BOOL)????....
bool collided(int arr[50][24], int row)
what is the meaning of bool is it related to C or C++???
if it is used for C++,what ı used for C which gives the same meaning
I could not understand where it is used (BOOL)????....
bool collided(int arr[50][24], int row)
what is the meaning of bool is it related to C or C++???
if it is used for C++,what ı used for C which gives the same meaning
#4
Re: from C++ to C
Posted 22 December 2005 - 04:54 PM
bool is like any other storage type (int, char, double, float) except it is only 1 bit big. Can only store 1 or 0. Thats why its boolean storage type.
bool functions return true or false, nothing else.
bool functions return true or false, nothing else.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|