上面的C语言版本够多的了,我写个C++版本好了~~~
#include
using namespace std;
void main()
{
int i = 1,t = 0;
for(;i < 100;i++)
{
if(i%2 == 0)
{
cout< t++;
}
if(t%5 == 0)cout<
}
#include
void main() { int i;
i=2; while ( i<=100 ) { printf("%d ",i); i+=2; } printf("\n");
}
也可以:
void main() { int i;
i=1;
while ( i<=100 ) {
if ( i%2==0 ) printf("%d ",i);
i++;
}
printf("\n");
}
# include
void main()
{
int i=1;
while(i<=100)
{
if(i%2==0)
printf("%d ",i);
i++;
}
}
#include
main()
{
int i=0;
while(i<=100)
{
i+=2;
printf("%d\n",i);
}
}
#include
main()
{ int i=0;
while(i<=100)
{
if(i!=0&&i%2==0){
printf("%d\n",i);
}
i++;
}