#include <iostream> #include <chrono> int main() { std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now(); std::cout << "3x4 ?" << std::endl; int result = 0; std::cin >> result; std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now(); int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>(end - start).count(); std::cout << "Result: " << result << "(" << (result == 12 ? "ok": "wrong") << ")" << ", elapsed time: " << elapsed_seconds << "s" << std::endl; return 0; }
Améliorer votre expérience CodeS-SourceS avec ce plugin:
http://codes-sources.commentcamarche.net/forum/affich-10000111-plugin-better-cs-2#cptpingu-signature
C:\Users\C........a\projets c++\chrono tables\main.cpp:11:57: error: 'std::chrono' has not been declared
int elapsed_seconds = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
// This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++0x_warning.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _CXX0X_WARNING_H #define _CXX0X_WARNING_H 1 #if __cplusplus < 201103L #error This file requires compiler and library support for the \ ISO C++ 2011 standard. This support is currently experimental, and must be \ enabled with the -std=c++11 or -std=gnu++11 compiler options. #endif #endif
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionstd::cout << "Press any key to end" << std::endl; std::cin.get();
Améliorer votre expérience CodeS-SourceS avec ce plugin:
http://codes-sources.commentcamarche.net/forum/affich-10000111-plugin-better-cs-2#cptpingu-signature