#include #include #define D1 100 #define D2 100 #define D3 10000 #define COLUM "%10.6f" int arr[D1][D2][D3]; void pwork(int val) { int *p = arr[0][0]; *p = val; p++; int *pend = p + D1 * D2 * D3; while (p < pend) { *(p++) = val; } } void awork(int val) { arr[0][0][0] = val; for (int i = 0; i < D1; i++) for (int j = 0; j < D2; j++) for (int k = 0; k < D3; k++) { arr[i][j][k] = val; } } void t1() { clock_t start, end; start = clock(); for (int i = 0; i < 10; i++) pwork(i); end = clock(); float cpu_time_used = ((float) (end - start)) / CLOCKS_PER_SEC; printf(COLUM, cpu_time_used ); } void t2() { clock_t start, end; start = clock(); for (int i = 0; i < 10; i++) awork(i); end = clock(); float cpu_time_used = ((float) (end - start)) / CLOCKS_PER_SEC; printf(COLUM, cpu_time_used ); } int main(int argc, char const *argv[]) { for (int i = 0; i < 10; i++) { t1(); t2(); printf("\n"); } return 0; }