Skip to content

Instantly share code, notes, and snippets.

@lv7777
Created July 19, 2016 16:17
Show Gist options
  • Save lv7777/7e81932628eef815c723488a28b2c125 to your computer and use it in GitHub Desktop.
Save lv7777/7e81932628eef815c723488a28b2c125 to your computer and use it in GitHub Desktop.
#include<stdlib.h>
#include<stdio.h>
// void dec2bin(int dec){
// char buf[100];
// printf("%s\n",itoa(dec, buf, 2));
// while(dec>0){
// // printf("%d",dec);
// if(dec%2){
// printf("1");
// }else{
// printf("0");
// }
// dec>>=1;
// }
// //return 2;
// }
int main(){
int * datas[]={128,192,224,240,248,252,254};
//char * ans[] ={"i","ia"}
int FLG=1;
char input[200];
char ans;
while(FLG){
int data=datas[rand()%6];
printf("%dを2進に直すと・・・?",data);
scanf("%s",&input);
char buf[200];
itoa(data,buf,2);
// void dec2bin(int dec){
// char buf[100];
printf("%s\n",itoa(data, buf, 2));
printf("%s==%s\n",input,buf);
if( !strcmp(input,"end") ){
printf("end\n");
return 0;
}
if(!strcmp(input,buf)){
printf("end\n");
return 0;
}
//printf("%s",&data);
}
// dec2bin(256);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment