diff --git a/Yang/1.c b/Yang/1.c deleted file mode 100644 index cb92f06..0000000 --- a/Yang/1.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include - -#define SIZE 10000000 - -void vectorAdd(float* A, float* B, float* C, int size) { - int i; - for (i = 0; i < size; ++i) { - C[i] = A[i] + B[i]; - } -} - -int main() { - float* A = (float*)malloc(SIZE * sizeof(float)); - float* B = (float*)malloc(SIZE * sizeof(float)); - float* C = (float*)malloc(SIZE * sizeof(float)); - if (A == NULL || B == NULL || C == NULL) { - return 1; - } - - // float A[SIZE], B[SIZE], C[SIZE]; - srand((unsigned)time(NULL)); - int i; - for (i = 0; i < SIZE; ++i) { - A[i] = rand() % 100; - B[i] = rand() % 100; - } - - - clock_t start_time = clock(); - - vectorAdd(A, B, C, SIZE); - - clock_t end_time = clock(); - double time = (double)(end_time - start_time) / CLOCKS_PER_SEC; - - printf("%f\n", time); - - // for (i = 0; i < SIZE; ++i) { - // printf("A[%d] + B[%d] = C[%d] -> %f + %f = %f\n", i, i, i, A[i], B[i], C[i]); - // } - - free(A); - free(B); - free(C); - return 0; -}