Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdio>
- #include <windows.h>
- COORD pos;
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- void SP (short x, short y)
- {
- pos.X = x;
- pos.Y = y;
- SetConsoleCursorPosition(hConsole, pos);
- }
- int pow (int a, int b)
- {
- int ans = 1;
- for (int i = 0; i < b; ++i){
- ans *= a;
- }
- return ans;
- }
- void read_lab(bool scan)
- {
- char path[8] = "1EX.txt";
- for (short i = 4; i <= 7; ++i){
- clock_t start = clock();
- path[2] = char ('0' + i);
- freopen(path, "r", stdin);
- double input;
- for (int c = 0; c < pow(10, i); ++c){
- if (scan) scanf("%f", &input);
- else std :: cin >> input;
- }
- double time = (clock() - start) / (double) CLOCKS_PER_SEC;
- if (scan) SP(5, i - 3);
- else SP(30, i - 3);
- printf("%.3f", time);
- }
- }
- void design_bold()
- {
- std::cout << '\n' << "1E4\n" << "1E5\n" << "1E6\n" << "1E7\n";
- }
- void solve()
- {
- design_bold();
- SP(5, 0);
- std :: cout << "Time for scanf(sec):";
- read_lab(true);
- SP(30, 0);
- std :: cout << "Time for cin(sec):";
- read_lab(false);
- }
- int main()
- {
- try {
- solve();
- } catch (...) {
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement