F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_39031203_16874.cpp:3:15: error: 'string' was not declared in this scope
    3 | int countOnes(string s) { int count = 0; for (char c : s) { if (c == '1') { count++; } } return count; }
      |               ^~~~~~
0_0_39031203_16874.cpp:3:15: note: suggested alternatives:
In file included from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/iosfwd:41,
                 from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ios:40,
                 from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ostream:40,
                 from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/iostream:41,
                 from 0_0_39031203_16874.cpp:1:
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/locale_classes.h:40,
                 from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/ios_base.h:41,
                 from gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ios:44:
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/string:66:11: note:   'std::pmr::string'
   66 |     using string    = basic_string<char>;
      |           ^~~~~~
0_0_39031203_16874.cpp: In function 'int main()':
0_0_39031203_16874.cpp:7:14: error: 'string' was not declared in this scope
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |              ^~~~~~
0_0_39031203_16874.cpp:7:14: note: suggested alternatives:
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/string:66:11: note:   'std::pmr::string'
   66 |     using string    = basic_string<char>;
      |           ^~~~~~
0_0_39031203_16874.cpp:7:43: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                           ^~~
      |                                           std::cin
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
0_0_39031203_16874.cpp:7:50: error: 'input' was not declared in this scope; did you mean 'int'?
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                  ^~~~~
      |                                                  int
0_0_39031203_16874.cpp:7:92: error: expected ';' before 's'
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                                                            ^~
      |                                                                                            ;
0_0_39031203_16874.cpp:7:103: error: 's' was not declared in this scope
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                                                                       ^
0_0_39031203_16874.cpp:7:127: error: 'countOnes' cannot be used as a function
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                                                                                      ~~~~~~~~~^~~
0_0_39031203_16874.cpp:7:255: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                                                                                                                                                                                                                               ^~~~
      |                                                                                                                                                                                                                                                               std::cout
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
0_0_39031203_16874.cpp:7:268: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    7 | int main() { string input; while (true) { cin >> input; if (input == "#") { break; } string s; cin >> s; int count = countOnes(s); char parity = input[input.size() - 1]; char correctParity = getParityChar(count, parity); s[s.size() - 1] = correctParity; cout << s << endl; } return 0; }
      |                                                                                                                                                                                                                                                                            ^~~~
      |                                                                                                                                                                                                                                                                            std::endl
gcc-13.1.0/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/ostream:735:5: note: 'std::endl' declared here
  735 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-26 17:20:33, Gzip enabled