#include<stdio.h> #include<math.h> int main() { unsigned int sum; int n,a1, q; scanf_s("%d", &n); a1 = 1; q = 2; sum = a1*(1 - pow(q,n) )/ (1 - q); printf("n=:%d,sun=%u\n", n, sum); return 0; }
不能,n取64时,计算结果数据过大,超出无符号整形的范围
标签:main,task3,int,sum,a1,include From: https://www.cnblogs.com/lht22MoonHalo/p/16801889.html