Skip to content

Instantly share code, notes, and snippets.

@fullmated
Created April 30, 2014 15:27
Show Gist options
  • Save fullmated/0282e84b3442f9e02648 to your computer and use it in GitHub Desktop.
Save fullmated/0282e84b3442f9e02648 to your computer and use it in GitHub Desktop.
0429課題まとめ
#include <stdio.h>
int main( int argc, char *argv[] ) {
int a, x;
a = 1;
scanf("%d", &x);
if( x <= 0 ){
printf("the data is less than 0\n");
}else{
while( a <= x ){
printf("%d\n", a);
if( a <= 1073741823 ) {
a = 2*a;
}else{
break;
}
}
}
return 0;
}
#include <stdio.h>
int main( int argc, char *argv[] ) {
int a, b, x;
a = 1;
b = 0;
scanf("%d", &x);
if( x <= 0 ){
printf("the data is less than 0\n");
}else{
while( a <= x ){
b = b+1;
if( a <= 1073741823 ) {
a = 2*a;
}else{
break;
}
}
printf("%d\n", b-1);
}
return 0;
}
#include <stdio.h>
int main( int argc, char *argv[] ) {
int b, x;
b = 0;
scanf("%d", &x);
if( x < 0 ){
printf("the data is less than 0\n");
}else{
while( x != 0 ){
if( x%2 == 1 ){
b = b+1;
}
x = x >> 1;
}
printf("%d\n", b);
}
return 0;
}
#include <stdio.h>
int main( int argc, char *argv[] ) {
int a, b, c, x;
a = 0;
b = 1;
c = 0;
scanf("%d", &x);
if( x < 0 ){
printf("the data is less than 0\n");
}else{
printf("0\n");
while( c <= x ){
c = a+b;
a = b;
b = c;
printf("%d\n", a);
}
}
return 0;
}
#include <stdio.h>
int main( int argc, char *argv[] ) {
int a, x;
a = 1;
scanf("%d", &x);
if( x <= 0 ){
printf("the data is less than 0\n");
}else{
while( a <= x ){
printf("%d\n", a);
if( a <= 715827882 ){
a = 3*a;
}else{
break;
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment