https://www.cnblogs.com/longhai3/longhai

C语言>>while循环1-100

Posted on 2022-02-12 19:26  凡是过去,皆为序曲  阅读(448)  评论(0编辑  收藏  举报

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/w1hg/331817