Created
April 30, 2014 15:27
-
-
Save fullmated/0282e84b3442f9e02648 to your computer and use it in GitHub Desktop.
0429課題まとめ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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