page1 | page2 | page3 | page5 | page6 | 大富豪カードPG | ロト6シミュレーションPG | メインページに戻る
ルンゲクッタ法 | フーリエ変換 | サイコロ | | | | |


  1. マトリックス風w
  2. #include <time.h>
    #include <stdlib.h>
    #include <iostream>
    
    #include <conio.h>
    #include <windows.h>
    #include <math.h>
    using namespace std;
    
    
    int main(){
    
        srand((unsigned int) time(NULL));
        int i,j,k,l,x,y,z,count = 0,MAX=80,mitu=1,timet=20;
        int m[120][120];
    
        HANDLE hStdout;
        WORD wAttributes;
    
    
        hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    
        for(i=0;i<MAX;i++){         //二次元配列の初期化
    
            for(j=0;j<MAX;j++){
                m[i][j]=1;
            }
        }
        cout <<log(2.0)/(0.0792232*log(10.0));
    
        //-----------------シミュレーション--------------------
        cout <<"-----マトリックスの開始-----"<<endl;
        cout <<"何秒実行しますか?";
        cin >> timet;
        cout <<"何かキーを押すとStart"<<endl;
        getch();
    
        for(int o=0;o<timet*5;o++){
            for(j=0;j<3700;j++){
                do{
                    y=rand()%MAX;
                    z=rand()%MAX;
                }while(m[y][z]==0);     //m[y][z]が1であればループを抜ける
    
            m[y][z]=0;
            }
    
            for(l=0;l<5700;l++){
                do{
                    y=rand()%MAX;
                    z=rand()%MAX;
                }while(m[y][z]==2);     //m[y][z]が2であればループを抜ける
    
            m[y][z]=2;
            }
    
        
            for(k=0;k<MAX;k++){
                for(x=0;x<MAX;x++){
                    if(m[k][x]==0){
                        wAttributes = FOREGROUND_GREEN;
                        SetConsoleTextAttribute(hStdout,wAttributes);
                        cout << m[k][x];
                    }
                    if(m[k][x]==1){
                        wAttributes = 7;
                        SetConsoleTextAttribute(hStdout,wAttributes);
                        cout << m[k][x];
                    }
                    if(m[k][x]==2){
                        wAttributes = 0;
                        SetConsoleTextAttribute(hStdout,wAttributes);
                        cout << m[k][x];
                    }
                }
            }
            
            for(i=0;i<MAX;i++){         //二次元配列の初期化
    
            for(j=0;j<MAX;j++){
                m[i][j]=1;
            }
            }
                
        }
        cout <<endl;
        wAttributes = 7;
        SetConsoleTextAttribute(hStdout,wAttributes);
        cout <<"-----マトリックス終了-----\n\n\n";
        getch();
        return 0;
    
    }