#include
int main()
{
int i=1,sum=0;
while(i<1000)
{
if(i%3==0) sum+=i;
}
printf("%d\n",sum);
return 0;
}
//假定已有上下文
//简单版
int i=0, sum=0;
while((i+=3) <= 1000) sum += i;
//穷举版
int i=0, sum=0;
while(i++ < 1000) if(i%3 == 0) sum += i;
#include
#include
#include
#include
#include
#include
#include
#include
int main(void)
{
//srand((unsigned) time(NULL));
//int n = rand() % 20;
int i = 3;
int sum = 0;
while(i < 1000)
{
if(i % 3 == 0)
{
sum = sum + i;
}
i++;
}
printf("sum = %d\n", sum);
return 0;
}