1.输出1~100,要求每行十个数
#include <iostream>
#include <iomanip>
#include<math.h>
using namespace std;
int main(){
int count = 0;
for(int i=1;i<=100;i++){
cout<<setw(3)<<i<<" ";
count++;
if(count == 10){
cout<<"\n";
count = 0 ;
}
}
}
2.输出1~100的偶数,要求每行十个数
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int count=0;
for(int i=1;i<=100;i++){
if(i % 2 == 0){
cout<<i<<" ";
count++;
if(count % 10 == 0)
cout<<"\n";
}
}
}