C言語なら俺に聞け(入門編)Part 61 at TECH
[2ch|▼Menu]
392:デフォルトの名無しさん
10/03/16 00:53:39
>>390

#include <stdio.h>
static int rnd(double* s){ int p; if(*s>1e+8){*s*=1e-4;}; if(*s<0){*s*=1e+8;} *s += *s*0.1; return((*s<0.0)?-*s:*s); }
void main(int argc, char** argv ) {
double n[1000]; double d; int n_max = 0; int i=0; double s =(double)((long)&n); rnd(&s);
FILE* fp = fopen( argv[1], "r"); for( ; fscanf( fp, "%lf", &d ) != EOF ; ){ n[n_max++]=d; }
for( i=0; i<5 ; ){ int r = rnd(&s)%n_max; if( n[r] != 1e+306 ) { printf( "%f\n", n[r] ); n[r]=1e+306; i++; }}
}

もぅ寝まつ…(つ_\


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5499日前に更新/110 KB
担当:undef