C++for循环

#include <iostream>
using namespace std;
int main() {
 double f;//holds the length in feet
 double m;//holds the conversion to meters
 int counter;
 
 counter =0;
  
 for(f= 1.0;f<=100.0;f++){
  m=f/3.28;//convent to meters
  cout<<f<<"feet is"<<m<<"meters.\n";
  
  counter++;
  
  //every 10th line,print a blant line
  if(counter ==10){
   cout<<"\n";//output a blank line
   counter =0;//reset the line count
  }
 }
 return 0;
}

猜你喜欢

转载自www.cnblogs.com/40630762-/p/12066046.html