Task: | Fraktaali |
Sender: | mika |
Submission time: | 2017-10-04 11:18:59 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'std::vector<std::basic_string<char> > reverse(std::vector<std::basic_string<char> >)': input/code.cpp:9:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < sq.size(); i++) { ^ input/code.cpp:11:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int j = 0; j < sq[i].length(); j++) { ^ input/code.cpp: In function 'std::vector<std::basic_string<char> > frak(int)': input/code.cpp:26:31: error: 'pow' was not declared in this scope vector<string> a(pow(2, n - 1)); ^ input/code.cpp:29:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < nn.size(); i++) { ^ input/code.cpp:33:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i...
Code
#include <iostream> #include <string> #include <vector> using namespace std; vector<string> reverse(vector<string> sq) { vector<string> v; for (int i = 0; i < sq.size(); i++) { string s; for (int j = 0; j < sq[i].length(); j++) { s += sq[i][j] == '#' ? '.' : '#'; } v.push_back(s); } return v; } vector<string> frak(int n) { if (n == 1) return vector<string> {{"#"}}; vector<string> nn = frak(n - 1); vector<string> rn = reverse(nn); vector<string> a(pow(2, n - 1)); // ylä for (int i = 0; i < nn.size(); i++) { a[i] = nn[i] + nn[i]; } //ala for (int i = nn.size(); i < nn.size()*2; i++) { a[i] = nn[i - nn.size()] + rn[i - nn.size()]; } return a; } void printV(vector<string> v) { for (int i = 0; i < v.size(); i++) { cout << v[i] << endl; }; cout << "" << endl; } int main() { int n; cin >> n; printV(frak(n)); return 0; }