C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- takezoh
- まろ
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- @tyottyoworks
- ___shanon
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
38
1
2
3
4
std::vector < std::vector <int> > interchange(std::vector < std::vector <int> > vect)5
{6
/* In : a 2d vector containing only binaries.7
Out : the previous 2d vector with the binaries interchanged. */8
9
for (int i = 0; i < vect.size(); i++)10
{11
for (int j = 0; j < vect[i].size(); j++)12
{13
if (vect[i][j] == 0)14
{15
vect[i][j] = 1;16
}17
else 18
{19
vect[i][j] = 0;20
}21
} 22
}23
24
return vect;25
}26
27
int main()28
{29
std::vector < std::vector <int> > vect // error : expected ';' at end of declaration30
{31
{1, 0, 1},32
{1, 1, 1},33
{0, 0, 1}34
};35
36
interchange(vect);37
}38
$ g++ prog.cc -Wall -Wextra -std=c++11 -pedantic
Start
prog.cc: In function 'std::vector<std::vector<int> > interchange(std::vector<std::vector<int> >)':
prog.cc:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for (int i = 0; i < vect.size(); i++)
| ~~^~~~~~~~~~~~~
prog.cc:11:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for (int j = 0; j < vect[i].size(); j++)
| ~~^~~~~~~~~~~~~~~~
0
Finish