Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programming some game

Name: Anonymous 2007-03-16 11:30 ID:+Cao99ew

Okay.. i'm a noob at C and i'm trying to do some game.
It's a game for 2 players. The first player inputs 4 numbers. The 2nd player tries to guess which numbers those are by inputting numbers too. If there is a correct number in wrong order, 0 will print. If there is a correct number in correct order, 1 will print. Game will end if the 2nd player gets 1111 or uses up all 10 turns.

I can't understand the array stuff much.. help me.

Name: Anonymous 2007-03-18 7:30 ID:huXMppok

#include <stdlib.h>
#include <stdio.h>

int main()
{
  int player1[4];
  int player2[4];
 
  int i;
 
  for(i=0;i<4;i++)
  {
  printf("Number %i ?", i+1);
  scanf("%i", &player1[i]);
  }
 
  system("clear");

  int mistake; 

  while(mistake!=0)
  {
  for(i=0;i<4;i++)
  {
  mistake=0;
  printf("Guess for number %i ?", i+1);
  scanf("%i", &player2[i]);
  }
 
  puts("Results:");
   
  for(i=0;i<4;i++)
  {
  if (player1[i]==player2[i])
    printf("1");
  else
    {
    printf("0");
    mistake++;
    }
  }
  puts("");
  if (mistake!=0)
  puts("Try again.");
  }
  puts("A winrar is you !");
  return 0;
}


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List