Hi everyone. This is my first post . I develop this program in C-Free 4.0 with <iostream> header... And it working
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
int main ()
{
int random_num;
srand((unsigned)time(0));
bool assigned_players[32];
for (int i=0;i<32;i++)
assigned_players[i] = false;
int n=32;
cout<<"Game Players"<<endl;
while (n>0){
random_num = (rand()%(32))+1;
if (!assigned_players[random_num-1]){
if ((32-n)%2==0){
cout<<(32-n)/2+1;
if (((32-n)/2+1)>9)
cout<<setw(8)<<random_num;
else
cout<<setw(9)<<random_num;
}
if ((32-n)%2==1)
cout<<" - "<<random_num<<endl;
assigned_players[random_num-1] = true;
n--;
}
}
return 0;
}
But when i rebuild it without <iostream> header. It came up with some errors. Can any please help me? Thanks you:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define SIZE 32
int main (void)
{
double x[SIZE];
int random_number;
int i, n;
srand((unsigned) time(0));
for (i=0;i<32;i++);
x[i] = "false";
n=32;
Printf("Game Player\n");
while (n>0){
random_number = (rand()%(32))+1;
if (!x[random_number-1]){
if ((32-n)%2==0){
printf("(32-n)/2+1\n");
if (((32-n)/2+1)>9)
printf("%d\n",random_number);
else
printf("%d\n",random_number);
}
if ((32-n)%2==1)
printf("-\n",random_number);;
x[random_number-1] = "true";
n--;
}
}
return 0;
}
Error is:
Checking file dependency...
Compiling C:\Program Files (x86)\C-Free 4\temp\Untitled1.cpp...
[Error] C:\Program Files (x86)\C-Free 4\temp\Untitled1.cpp:13: assignment to `double' from `const char *'
[Error] C:\Program Files (x86)\C-Free 4\temp\Untitled1.cpp:15: implicit declaration of function `int Printf(...)'
[Error] C:\Program Files (x86)\C-Free 4\temp\Untitled1.cpp:31: assignment to `double' from `const char *'