大家帮忙看看我这句循环函数错在哪了?
求(1+2+3+....+100)+(1*1+2*2+3*3+....+50*50)的值#include "stdio.h"
#include "math.h"
void main()
{
unsigned long int i,j,x=0;
unsigned long int y=0,z,all;
for(i=1;i<=100;i++)
x=x+i;
for(j=1;j<=50;j++)
{z=j*j;
y=y+z;}
all=x+y;
printf("The answer is :%d",all);
getchar();
}
结果是负值,应该是溢出了,可我定义的是无符号长整形,应该不会阿~~