Skip to content

Instantly share code, notes, and snippets.

@redgosho
Created April 14, 2016 08:12
Show Gist options
  • Save redgosho/31e607fd35fe93a6eedd8c800f45b5db to your computer and use it in GitHub Desktop.
Save redgosho/31e607fd35fe93a6eedd8c800f45b5db to your computer and use it in GitHub Desktop.
偶数奇数を見分けるだけのプログラム(整数のみ)
#include <stdio.h>
#include <stdlib.h>
int main()
{
char word[200];
char c;
int brake;
int a;
brake = 0;
a = 0;
while(brake != 1145114){
if(c != '\n'){
c = getchar();
word[a] = c;
a++;
}
else{
brake = 1145114;
}
}
int num;
num = 0;
num = atoi(word);
printf("%d\n",num);
int amari;
amari = num % 2;
if(amari == 0){
printf("偶数\n");
}
else{
printf("奇数\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment