Submission #20243

#TimeUsernameProblemLanguageResultExecution timeMemory
20243pk8498분배 (kriii3_Q)C++98
Compilation error
0 ms0 KiB
#include <string> #include <vector> #include <iostream> #include <cmath> namespace test { class test { public: virtual void testNum *berDistribution(); }; } namespace test { using org::junit::Test; void testNum *test::berDistribution() { int k = 3; int n = 1; if (k == n | k < 1 | n > 16) { std::cout << std::string(" Please check the number again. ") << std::endl; return; } // if k>n, swap if (k > n) { k = k ^ n ^ (n = k); } // set row,col int rows = static_cast<int>(std::pow(2, k)); int cols = static_cast<int>(std::pow(2, n - k - 1)); int arrayLength = static_cast<int>(std::pow(2, n)); // set natural number std::vector<int> number(arrayLength); for (int i = 0; i < arrayLength; i++) { number[i] = i; } int count = 0; // console print for (int rowIndex = 0; rowIndex < rows; rowIndex++) { for (int colIndex = 0; colIndex < cols; colIndex++) { std::cout << count << std::string(" ") << number[arrayLength - count - 1]; count++; if (colIndex > cols - 1) { continue; } std::cout << std::string(" "); } // end of colIndex std::cout << std::endl; } // end of rowIndex } }

Compilation message (stderr)

Q.cpp:12:19: error: variable or field 'testNum' declared void
      virtual void testNum *berDistribution();
                   ^
Q.cpp:12:19: error: expected ';' at end of member declaration
Q.cpp:12:44: error: ISO C++ forbids declaration of 'berDistribution' with no type [-fpermissive]
      virtual void testNum *berDistribution();
                                            ^
Q.cpp:17:11: error: 'org' has not been declared
     using org::junit::Test;
           ^
Q.cpp:19:18: error: expected initializer before '*' token
     void testNum *test::berDistribution()
                  ^
Q.cpp:68:4: error: expected '}' at end of input
    }
    ^