- 360 名前:デフォルトの名無しさん [2007/06/12(火) 20:18:53 ]
- 入力した自然数を4で割り、4つの変数に収めた後、
余りをランダムに割り振るプログラムを書いて見ました #include<ctime> #include<cstdlib> #include<iostream> using namespace std; int main() { int a;//適当な大きさの変数を読み取らせるための変数 int c1; int c2; int c3; int c4;//aを4で割り、余りをこの4つの数値にランダムに格納する int b; c1=c2=c3=c4=0; scanf("%d",&a); b=a % 4; printf("%d,%d\n",a/4,b); printf("%d,%d,%d,%d\n",c1,c2,c3,c4); while(b>0) { srand(time(NULL)); int dice=rand() % 4;
|

|