Demo entry 6688539

c++

   

Submitted by 刘秦 on Jan 03, 2018 at 14:02
Language: C++. Code size: 683 Bytes.

#include <iostream>
#include <ctime>

using std::cout;
using std::endl;

const int TIMES_OF_CYCLE = 100000000;

int main( void )
{
    int a[ 10 ] = { 0 };
    clock_t Start, End;
    Start = clock();
    for( int j = 0; j < TIMES_OF_CYCLE; ++j )
        for( int i = 0; i < 10; ++i )
            a[ i ] = 10;
    End = clock();
    cout << static_cast< double > ( End - Start ) / CLOCKS_PER_SEC << endl;
    Start = clock();
    for( int j = 0; j < TIMES_OF_CYCLE; ++j )
        for( int *p = a, *q = a + 10; p < q; ++p )
            *p = 10;
    End = clock();
    cout << static_cast< double > ( End - Start ) / CLOCKS_PER_SEC << endl;
    return 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).