#include"head_file.h" #include#include int main() { timeb t1, t2;//定義兩個變量 long t; double x, sum = 0, sum1=1; int i, j, n; printf("請輸入x n:"); scanf("%lf %d",&x,&n); ftime(&t1);//記錄開始的時間 for (i = 0; i < n; ++i) { sum1 = sum1*(-1/x); sum += sum1; } ftime(&t2);//記錄結束的時間 t = (t2.time - t1.time) * 1000 + (t2.millitm - t1.millitm);//計算程序運行的時間 printf("sum is %ld,and time is :%ld\n",sum,t); return 0; }