1-100偶数和
#include<stdio.h>
int main()
{
int a=0,b=1;
while(b<=100)
{
if(b%2==0)
{
a=a+b;
}
b++;
}
printf("%d",a);
return 0;
}
=====================================================================
1-100被23同时除的和
#include<stdio.h>
int main()
{
int a=0,b=1;
while(b<=100)
{
if(b%2==0&&b%3==0)
{
a=a+b;
}
b++;
}
printf("%d",a);
return 0;
}
=====================================================================
1-100和
#include<stdio.h>
int main()
{
int a=0,b=1;
while(b<=100)
{
a=a+b++;
}
printf("%d",a);
return 0;
}
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=
本文来自博客园,作者:凡是过去,皆为序曲,转载请注明原文链接:https://www.cnblogs.com/longhai3/p/15887150.html
如有疑问,欢迎提问
#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=#+=