for循环应用
#include <iostream>
using namespace std;
int main()
{
double earthweight;
double moonweight;
int counter;
counter=0;
for(earthweight=1.0;earthweight<=100.0;earthweight++){
moonweight=earthweight*0.17;
cout<<earthweight<<"earth-pounds is equivalent to";
cout<<moonweight<<"moon-pounts.\n";
counter++;
if(counter==25){
cout<<"\n";
}
}
return 0;
}
{
double earthweight;
double moonweight;
int counter;
counter=0;
for(earthweight=1.0;earthweight<=100.0;earthweight++){
moonweight=earthweight*0.17;
cout<<earthweight<<"earth-pounds is equivalent to";
cout<<moonweight<<"moon-pounts.\n";
counter++;
if(counter==25){
cout<<"\n";
}
}
return 0;
}

浙公网安备 33010602011771号