c++ - About the use of GetTickCount()
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-31 10:38:40
0
1
734

Dear friends, after I use GetTickCount(), an error is output. Please ask for help. A screenshot is attached below. Many thanks!


#include<iostream>
#include<windows.h>
#include<fstream>
using namespace std;
ifstream infile("test.txt");
int main()
{
    int n,i=1,j,a[100000];
    DWORD time1,time2;
    while(!infile.eof()) infile>>a[i++];
    n=i-1;
    time1=GetTickCount();
    for(i=1;i<n;i++)
        for(j=1;j<n;j++)
            if(a[j]<a[j+1])
                swap(a[j],a[j+1]);   //冒泡排序
    time2=GetTickCount();
    cout<<time1-time2<<endl;
    return 0;
}


Sometimes the result will still be 0. When I was debugging, I saw that the penultimate step was still correct, but the final output result was wrong. . . Please help me, thank you very much

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
过去多啦不再A梦

Shouldn’t it be time2-time1

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template