Skip to content

Instantly share code, notes, and snippets.

@leostera
Created August 23, 2011 17:23
Show Gist options
  • Save leostera/1165915 to your computer and use it in GitHub Desktop.
Save leostera/1165915 to your computer and use it in GitHub Desktop.
Problema 38
#include <stdio.h>
int main(int argc, char ** argv)
{
int jugando = 0;
char c;
while(jugando == 0)
{
int n=0;
printf("Ingrese la cantidad de tiros: ");
scanf("%d", &n);
float coordsX [n];
float coordsY [n];
int puntaje=0;
int i=0;
for(i=0; i<n; i++)
{
printf("(X,Y): ");
scanf("%f,%f", &coordsX[i], &coordsY[i]);
if(coordsX[i] > -1 && coordsX[i] < 1 && coordsY[i] > -1 && coordsY[i] < 1)
{
puntaje += 4;
}
else if(coordsX[i] > -2 && coordsX[i] < 2 && coordsY[i] > -2 && coordsY[i] < 2)
{
puntaje += 3;
}
else if(coordsX[i] > -3 && coordsX[i] < 3 && coordsY[i] > -3 && coordsY[i] < 3)
{
puntaje += 2;
}
else if(coordsX[i] > -4 && coordsX[i] < 4 && coordsY[i] > -4 && coordsY[i] < 4)
{
puntaje += 1;
}
}
printf("Tu puntaje total fue de: %d", puntaje);
printf("\nJugar de nuevo? (S/N): ");
fflush(stdin);
scanf("%c",&c);
if(c == 'S' || c == 's')
{
jugando = 0;
}
else
{
jugando = 1;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment