2.3 Comparison of the two algorithms

1+2+3+…+100

#include<stdio.h>
int main()
{
int i,m=0;
for(i=1;i<=100;i++)
m=m+i;
printf("%d\n",m);
}

#include<stdio.h>
int main()
{
int m;
m=(1+100)*(100/2);
printf("%d\n",m);
}

Guess you like

Origin blog.csdn.net/m0_53052839/article/details/115332436