很多循环语句都可以做的
#include "stdio.h"
void main()
{
int i,N,S;
i=0;
S=0;
printf("Please into a number N:");
scanf("%d",&N);
while(i<=N)
{
S=S+i;
i++;
}
printf("The end number is:%d",S);
}
再说个,
void main()
{
int i,N,s=0;
printf("Please into a number N:");
scanf("%d",&N);
for(i=1;i<=N;i++)
{
s=s+i;
}
printf("The end number is:%d",s);
}
#include "stdio.h"
void main()
{
int i,N,S;
i=0;
S=0;
printf("Please into a number N:");
scanf("%d",&N);
while(i<=N)
{
S=S+i;
i++;
}
printf("The end number is:%d",S);
}
再说个,
void main()
{
int i,N,s=0;
printf("Please into a number N:");
scanf("%d",&N);
for(i=1;i<=N;i++)
{
s=s+i;
}
printf("The end number is:%d",s);
}