-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnineNine.cpp
More file actions
54 lines (47 loc) · 1.63 KB
/
nineNine.cpp
File metadata and controls
54 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
// 参照渡しを用いて、呼び出し側の変数の値を変更する
void saiten(vector<vector<int>> &A,int &correct_count,int &wrong_count/* 呼び出し側に対応するように引数を書く */) {
// 呼び出し側のAの各マスを正しい値に修正する
for (int i = 0; i<A.size(); i++){
for(int j = 0; j<A.at(i).size();j++){
if (A.at(i).at(j) != i*j){
wrong_count++;
A.at(i).at(j) = i*j;
}else{
correct_count++;
}
}
}
// Aのうち、正しい値の書かれたマスの個数を correct_count に入れる
// Aのうち、誤った値の書かれたマスの個数を wrong_count に入れる
// ここにプログラムを追記
}
// -------------------
// ここから先は変更しない
// -------------------
int main() {
// A君の回答を受け取る
vector<vector<int>> A(9, vector<int>(9));
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
cin >> A.at(i).at(j);
}
}
int correct_count = 0; // ここに正しい値のマスの個数を入れる
int wrong_count = 0; // ここに誤った値のマスの個数を入れる
// A, correct_count, wrong_countを参照渡し
saiten(A, correct_count, wrong_count);
// 正しく修正した表を出力
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
cout << A.at(i).at(j);
if (j < 8) cout << " ";
else cout << endl;
}
}
// 正しいマスの個数を出力
cout << correct_count << endl;
// 誤っているマスの個数を出力
cout << wrong_count << endl;
}