Click here to Skip to main content
15,886,046 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Script generation from Objects using C++ Pin
FrankStar8912-Nov-18 11:19
FrankStar8912-Nov-18 11:19 
GeneralRe: Script generation from Objects using C++ Pin
CPallini12-Nov-18 21:18
mveCPallini12-Nov-18 21:18 
AnswerRe: Script generation from Objects using C++ Pin
leon de boer6-Nov-18 14:30
leon de boer6-Nov-18 14:30 
GeneralRe: Script generation from Objects using C++ Pin
FrankStar8912-Nov-18 11:22
FrankStar8912-Nov-18 11:22 
QuestionGames Pin
Member 140425973-Nov-18 5:24
Member 140425973-Nov-18 5:24 
AnswerRe: Games Pin
OriginalGriff3-Nov-18 5:27
mveOriginalGriff3-Nov-18 5:27 
AnswerRe: Games Pin
CPallini4-Nov-18 21:50
mveCPallini4-Nov-18 21:50 
QuestionConways Game of life game in C Pin
Abhinav99933-Nov-18 1:27
Abhinav99933-Nov-18 1:27 
============================================================================
Name : new.c
Author : Abhinav
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/

include <stdio.h>

include <stdlib.h>


void compute(int N[6][6],int Z[6][6])
{
//compute neighbours
int i,j;
for (i = 1; i <=6; i++)
{
    for (j = 1; j <= 6; j++)
    {
        N[i][j]=Z[i-1][j-1]+Z[i][j-1]+Z[i+1][j-1]
           + Z[i-1][j] +Z[i+1][j]+ Z[i-1][j+1]
           +Z[i][j+1]+Z[i+1][j+1];
    }
}

}

// This method is going to print the Matrix that we have defined in the main method
void show(int Z[6][6])
{
printf("************************************************************\n");
int i,j;
// Incrementing the value of integer i so that it can be used as an index value for matrix 'Z'.
for (i = 0; i < 6; i++)
{
    // Incrementing the value of integer j to be used as the second index value for matrix 'Z'.
    for (j = 0; j < 6; j++)
    {
        // This will print the elements present in th array line wise.
        printf("%d ", Z[i][j]);
    }
    printf("\n");
}

printf("************************************************************\n");
}
/* This method is going to take the value of elements
from the array and compute the output according to
some conditions. Like for the rule of UnderPopulation
we have to check that if the element at some index is surrounded
by less than two live elements than the element is going to die.
*/
void iteration(int Z[6][6]){
int N[6][6]= {{0}};
int i,j;
compute(N,Z);

for (i = 0; i < 6; i++)
{
    for (j = 0; j < 6; j++)
    {
        if((Z[i][j] == 1)&&(N[i][j] < 2 || N[i][j] > 3))
        {
            Z[i][j] = 0;
        }
        else if((Z[i][j] == 0)&&(N[i][j] == 3))
        {
            Z[i][j] = 1;
        }
    }
}

/*
for (i = 0; i < 6; i++)
{
for (j = 0; j < 6; j++)
{
if((N[i][j] < 2 )) // Rule number 1 - Under population
{
if (Z[i][j]==1&&((N[i][j] ==2 )||(N[i][j] == 3 ))) // Rule 4 - Next generation
{
Z[i][j] = 1;
}
else
{
Z[i][j] = 0;
}
        }
        else if ((Z[i][j] == 0)&&(N[i][j]==3)) // Rule 2 - Dead cell become live
        {
            Z[i][j] = 1;
        }
        else if ((N[i][j]>3)) // Rule 3 - Overpopulation
        {
            Z[i][j] = 0;
        }
    }
}
*/

}
/*
In this main method all the method are called to execute
all the methods.
*/
int main()
{
// Here I have declared a 6x6, 2D array which contains 36 elements.
int Z[6][6]=
{
    // In this array '1' denotes live cell where as '0' denotes dead cell.

    {1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 0, 0},
    {0, 1, 0, 1, 0, 0},
    {0, 0, 1, 1, 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0},
};
// This will pass the value of elements of array into the method 'show()'

int i;
printf("Here is the array that i have declared for the GAME.\n");
show(Z);
printf("\n");

printf("****************************************************************\n");
printf("Actual output after computing the results\n");
for(i=1; i<= 5; i++) // This will tell us the number of generations to skip before the answer
{
    //clear(); //clear screen
    iteration(Z);
    printf("#################################################");
    printf("This is the %d generation",i);
    show(Z);

}

printf("****************************************************************\n");
return 0;

}
AnswerRe: Conways Game of life game in C Pin
Richard MacCutchan3-Nov-18 3:57
mveRichard MacCutchan3-Nov-18 3:57 
AnswerRe: Conways Game of life game in C Pin
元昊 潘3-Nov-18 4:04
元昊 潘3-Nov-18 4:04 
GeneralRe: Conways Game of life game in C Pin
Victor Nijegorodov3-Nov-18 6:33
Victor Nijegorodov3-Nov-18 6:33 
GeneralHow to solve memory resource management problems in C++ Pin
元昊 潘2-Nov-18 22:55
元昊 潘2-Nov-18 22:55 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 3:56
mveRichard MacCutchan3-Nov-18 3:56 
AnswerRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 4:39
元昊 潘3-Nov-18 4:39 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 4:51
mveRichard MacCutchan3-Nov-18 4:51 
AnswerRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 5:04
元昊 潘3-Nov-18 5:04 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 10:02
mveRichard MacCutchan3-Nov-18 10:02 
AnswerRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 16:26
元昊 潘3-Nov-18 16:26 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 21:17
mveRichard MacCutchan3-Nov-18 21:17 
AnswerRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 22:00
元昊 潘3-Nov-18 22:00 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 22:18
mveRichard MacCutchan3-Nov-18 22:18 
GeneralRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 22:30
元昊 潘3-Nov-18 22:30 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 22:34
mveRichard MacCutchan3-Nov-18 22:34 
PraiseRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 23:44
元昊 潘3-Nov-18 23:44 
GeneralRe: How to solve memory resource management problems in C++ Pin
Stefan_Lang13-Nov-18 22:52
Stefan_Lang13-Nov-18 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.