-
-
Save tdkn/2886823 to your computer and use it in GitHub Desktop.
kadai 20120606
This file contains hidden or 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 i,j; | |
int param; | |
param = atoi(argv[1]); | |
for(i=0; i<param; i++) { | |
for(j=0; j<i+1; j++) { | |
printf("x"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or 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 i,j; | |
int param; | |
param = atoi(argv[1]); | |
for(i=0; i<param; i++) { | |
for(j=0; j<param-(1+i); j++) { | |
printf(" "); | |
} | |
for(j=0; j<i+1; j++) { | |
printf("x"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or 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 i,j; | |
int param; | |
param = atoi(argv[1]); | |
for(i=0; i<param; i++) { | |
for(j=0; j<param-(1+i); j++) { | |
printf(" "); | |
} | |
for(j=0; j<2*i+1; j++) { | |
printf("x"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or 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 (void) { | |
int i; | |
int input[5] = {0}; | |
for(i=0; i<5; i++) { | |
printf("Input : "); | |
scanf("%d",&input[i]); | |
} | |
for(i=0; i<5; i++) { | |
printf("%d ",input[(5-1)-i]); | |
} | |
return 0; | |
} |
This file contains hidden or 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(void) { | |
int i; | |
int a[5] = {0}; | |
int query = 0; | |
int count = 0; | |
for(i=0; i<5; i++) { | |
printf("Input : "); | |
scanf("%d",&a[i]); | |
} | |
printf("Search number : "); | |
scanf("%d",&query); | |
for(i=0; i<5; i++) { | |
if(query == a[i]) { | |
count++; | |
printf("a[%d]=%d\n",i,query); | |
} | |
} | |
printf("Number of match = %d\n",count); | |
return 0; | |
} |
This file contains hidden or 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> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(void) { | |
int i,r; | |
i = rand(); | |
i = i%2; | |
int num = 50; | |
int x[num]; | |
int b[10] = {0}; | |
srand((unsigned int) time(NULL)); | |
for(i=0; i<num; i++) { | |
r = rand() % 10; | |
x[i] = r; | |
b[r]++; | |
printf(" %d,",r); | |
if(i%10 == 9) { | |
printf("\n"); | |
} | |
} | |
for(i=0; i<10; i++) | |
printf("%dは%d個\n",i,b[i]); | |
return 0; | |
} |
This file contains hidden or 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> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(void) { | |
int i,j,r; | |
i = rand(); | |
i = i%2; | |
int num = 50; | |
int x[num]; | |
int b[10] = {0}; | |
srand((unsigned int) time(NULL)); | |
for(i=0; i<num; i++) { | |
r = rand() % 10; | |
x[i] = r; | |
b[r]++; | |
printf(" %d,",r); | |
if(i%10 == 9) { | |
printf("\n"); | |
} | |
} | |
for(i=0; i<10; i++) { | |
printf("%d:",i); | |
for(j=0; j<b[i]; j++) { | |
printf("X"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
This file contains hidden or 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> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(void) { | |
int i,j,r; | |
i = rand(); | |
i = i%2; | |
int num = 50; | |
int x[num]; | |
int b[10] = {0}; | |
int max = 0; | |
srand((unsigned int) time(NULL)); | |
for(i=0; i<num; i++) { | |
r = rand() % 10; | |
x[i] = r; | |
b[r]++; | |
} | |
for(i=0; i<10; i++) { | |
max = (max < b[i]) ? b[i] : max; | |
printf("%3d",b[i]); | |
} | |
printf("\n\n"); | |
for(i=0; i<max; i++) { | |
for(j=0; j<10; j++) { | |
if((0 < b[j] && b[j] <= max) && ((max-i) <= b[j])) { | |
printf(" X"); | |
} else { | |
printf(" "); | |
} | |
} | |
printf("\n"); | |
} | |
printf("------------------------------\n"); | |
printf(" 0 1 2 3 4 5 6 7 8 9\n"); | |
return 0; | |
} |
This file contains hidden or 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> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(void) { | |
int i=0,j=0,k=0; | |
int tmp=0; | |
int map[5][5]={0},buf[5][15]={0}; | |
srand((unsigned int) time(NULL)); | |
// 配列に1-75の値を格納 | |
for(i=0; i<5; i++) { | |
for(j=0; j<15; j++) { | |
buf[i][j] = k + 1; | |
k++; | |
} | |
} | |
// 2次配列をシャッフル | |
for(i=0; i<5; i++) { | |
for(j=14; j; j--) { | |
tmp = buf[i][j]; | |
k = rand() % (j + 1); | |
buf[i][j] = buf[i][k]; | |
buf[i][k] = tmp; | |
} | |
} | |
puts(" B I N G O "); | |
// ビンゴカードを描画 | |
for(i=0; i<5; i++) { | |
for(j=0; j<5; j++) { | |
if(i == 2 && j == 2) { | |
printf(" "); | |
} else { | |
printf("%3d", map[i][j]=buf[j][i]); | |
} | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment