C语言编写1+100的和怎么编?
C语言编写1+100的和怎么编?
日期:2021-09-07 06:14:18 人气:1
#include <stdio.h>
#define ONE_TO_N(n) ((1UL+(n))*(n)/2UL)
int main(void)
{
printf("1+...+100 = %d\n", ONE_TO_N(100));
return 0;
}
#define ONE_TO_N(n) ((1UL+(n))*(n)/2UL)
int main(void)
{
printf("1+...+100 = %d\n", ONE_TO_N(100));
return 0;
}