#include #include #include #define SIZE 1024 void vector_add(float* A, float* B, float* C, int size) { for (int i = 0; i < size; i++) { C[i] = A[i] + B[i]; } } int main() { float A[SIZE], B[SIZE], C[SIZE]; srand(time(NULL)); for (int i = 0; i < SIZE; i++) { A[i] = rand() % 100; B[i] = rand() % 100; } clock_t start, end; start = clock(); vector_add(A, B, C, SIZE); end = clock(); double time_spent = (double)(end - start) / CLOCKS_PER_SEC; printf("基础向量加法的运行时间为: %lf 秒\n", time_spent); return 0; }