Skip to content

Instantly share code, notes, and snippets.

@WadsonGarbes
Created August 23, 2019 22:34
Show Gist options
  • Save WadsonGarbes/bcfad7482108aefb9a6d1a788d745bdc to your computer and use it in GitHub Desktop.
Save WadsonGarbes/bcfad7482108aefb9a6d1a788d745bdc to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int par_ou_impar(char *S)
{
int i, j, cont;
j = strlen(S);
for(i = 0; i < j; i++)
{
if(S[i] == '1')
cont++;
}
return (cont % 2) ? 1 : 0;
}
int main(void)
{
char *S;
int num;
scanf("%s", S);
num = par_ou_impar(S);
(num) ? puts(strcat(S, "0")) : puts(strcat(S, "1"));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment