/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class NewClass {
public static void main(String[] args) {
int i = 1;
int sum = 0;
while (i <= 100) {
if (i % 3 == 0) {
sum = sum + i;
}
i++;
}
System.out.println(sum);
}
}
答案是1683
#include
int main()
{int i,s=0;
for(i=3;i<100;i+=3)
s+=i;
printf("%d\n",s);
return 0;
}