1, [Error] 'cout' does not name a type
The reason for this is "cout << ..." This line statement not put the main function, which is not in braces, and I wrote a multi-braces.
2, [Error] 'cnt' was not declared in this scope
This is your definition of a cnt such thing in the loop, such as to count.
This error occurs cnt final output. .
So you define to define to the outside.