大樂透作業

 avatar
YTC
c_cpp
3 years ago
4.3 kB
5
Indexable
// {{17, 27, 30, 38, 42, 44, 24},{3, 4, 15, 29, 32, 39, 38},{1, 3, 16, 17, 24, 25, 46},{5, 6, 19, 24, 33, 41, 3},{2, 11, 29, 33, 41, 44, 40},{3, 6, 11, 13, 18, 37, 46},{1, 5, 17, 36, 40, 41, 38},{8, 11, 16, 32, 35, 43, 41},{7, 14, 23, 43, 47, 49, 48},{18, 21, 24, 32, 41, 1, 12},{27, 48, 45, 4, 20, 26, 37},{28, 1, 16, 41, 5, 15, 44},{13, 18, 40, 41, 9, 22, 49},{35, 18, 12, 45, 37, 7, 44},{34, 28, 31, 2, 16, 13, 21},{4, 10, 39, 42, 21, 30, 22},{27, 36, 24, 47, 23, 49, 40},{49, 22, 2, 9, 16, 41, 7},{46, 23, 47, 3, 11, 1, 45},{18, 19, 37, 44, 34, 20, 10},{26, 28, 31, 14, 1, 6, 30},{37, 2, 26, 21, 25, 12, 10},{39, 21, 35, 26, 47, 20, 16},{25, 13, 46, 27, 38, 8, 12},{26, 49, 21, 18, 47, 14, 30},{42, 2, 17, 36, 9, 28, 46},{17, 1, 12, 43, 37, 21, 47},{16, 40, 26, 44, 30, 18, 13},{9, 14, 20, 42, 39, 26, 5},{25, 37, 2, 47, 3, 27, 26},{23, 34, 6, 44, 43, 41, 38},{16, 36, 17, 15, 23, 13, 29},{13, 32, 7, 37, 33, 6, 42},{15, 30, 10, 21, 16, 22, 14},{9, 26, 10, 31, 49, 40, 8},{41, 35, 8, 14, 36, 13, 5},{43, 44, 21, 30, 19, 48, 8},{24, 27, 40, 3, 15, 21, 13},{30, 14, 7, 21, 36, 27, 43},{35, 11, 2, 40, 37, 30, 13},{27, 44, 31, 48, 5, 4, 33},{19, 27, 11, 2, 44, 7, 22},{11, 1, 2, 21, 8, 45, 16},{14, 34, 5, 37, 9, 28, 35},{43, 16, 29, 24, 27, 21, 41},{45, 47, 49, 14, 22, 17, 26},{7, 21, 26, 36, 43, 49, 16},{2, 15, 21, 26, 42, 44, 45},{1, 31, 33, 37, 46, 47, 36},{3, 4, 8, 15, 21, 24, 29},{13, 14, 16, 19, 30, 44, 20},{1, 3, 18, 29, 30, 31, 26},{7, 17, 19, 24, 31, 45, 38},{17, 18, 21, 26, 38, 49, 20},{3, 21, 22, 34, 37, 40, 5},{16, 20, 36, 39, 47, 48, 35},{18, 23, 26, 27, 40, 42, 3},{23, 24, 30, 42, 44, 46, 48},{1, 22, 25, 27, 41, 44, 3},{2, 7, 11, 18, 35, 45, 25},{5, 23, 29, 33, 38, 49, 24},{3, 18, 23, 32, 40, 45, 38},{12, 24, 29, 34, 38, 42, 33},{2, 4, 13, 36, 41, 49, 16},{22, 9, 34, 5, 36, 18, 11},{6, 33, 11, 18, 23, 41, 39},{25, 45, 47, 8, 44, 34, 24},{14, 33, 43, 44, 32, 4, 49},{23, 15, 8, 20, 22, 3, 36},{1, 23, 34, 2, 20, 26, 19},{12, 44, 36, 41, 7, 42, 29},{15, 10, 35, 27, 2, 9, 44},{15, 42, 27, 37, 26, 34, 47},{19, 48, 33, 35, 22, 38, 11},{24, 5, 26, 35, 14, 13, 39},{49, 36, 17, 13, 10, 11, 41},{31, 15, 6, 39, 9, 38, 25},{7, 4, 19, 43, 3, 22, 36}};
// 這是我自己整理好的大樂透110年8月到111年3月資料,宣告矩陣之後在等號後面直接複製貼上就能用了,有需要的人歡迎自行取用
//  main.cpp
//  codehomework#05 lottery
//
//  Created by YTC on 222/3/29.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    vector<vector <int>> array ={{43, 16, 29, 24, 27, 21, 41},{45, 47, 49, 14, 22, 17, 26},{7, 21, 26, 36, 43, 49, 16},{2, 15, 21, 26, 42, 44, 45},{1, 31, 33, 37, 46, 47, 36},{3, 4, 8, 15, 21, 24, 29},{13, 14, 16, 19, 30, 44, 20},{1, 3, 18, 29, 30, 31, 26},{7, 17, 19, 24, 31, 45, 38},{17, 18, 21, 26, 38, 49, 20},{3, 21, 22, 34, 37, 40, 5},{16, 20, 36, 39, 47, 48, 35},{18, 23, 26, 27, 40, 42, 3},{23, 24, 30, 42, 44, 46, 48},{1, 22, 25, 27, 41, 44, 3},{2, 7, 11, 18, 35, 45, 25},{5, 23, 29, 33, 38, 49, 24},{3, 18, 23, 32, 40, 45, 38},{12, 24, 29, 34, 38, 42, 33},{2, 4, 13, 36, 41, 49, 16},{22, 9, 34, 5, 36, 18, 11},{6, 33, 11, 18, 23, 41, 39},{25, 45, 47, 8, 44, 34, 24},{14, 33, 43, 44, 32, 4, 49},{23, 15, 8, 20, 22, 3, 36},{1, 23, 34, 2, 20, 26, 19},{12, 44, 36, 41, 7, 42, 29},{15, 10, 35, 27, 2, 9, 44},{15, 42, 27, 37, 26, 34, 47},{19, 48, 33, 35, 22, 38, 11},{24, 5, 26, 35, 14, 13, 39},{49, 36, 17, 13, 10, 11, 41},{31, 15, 6, 39, 9, 38, 25},{7, 4, 19, 43, 3, 22, 36}};//自111年1月至今開獎號碼
    
    cout << "大樂透各期開獎號碼: "<<endl;
    for(int i = 0 ; i < array.size() ;i++){
        cout << "期數" << 111000001 + i << ": ";
        for(int j = 0 ; j < array.at(i).size();j++)
        {
            cout<< array[i][j]<<" ";
        }
        cout<< endl;
    }
    cout<< endl<< "開獎號碼出現次數統計如下: "<< endl;
   
    vector<int> onedimentional(array.size()*7);
    
    for(int i = 0 ;i < array.size(); i++)
    {
        for(int j = 0 ; j < array.at(i).size();j++){
            onedimentional[i*7+j] = array[i][j];
        }
    }
    for(int num = 1 ; num < 50 ; num++)
    {
        cout<< num <<": " <<count(onedimentional.begin(),onedimentional.end(),num)<< "次\n";
    }
    
    return 0;
}
Editor is loading...