99乘法表2
2017-09-16 08:48
113 查看
#include<iostream> #include<iomanip> using namespace std; int main(){ int a[10]={1,1,2,3,4,5,6,7,8,9}; cout<<setw(3)<<setfill(' ')<<"*"; for(int i=1;i<=9;i++) cout<<setw(3)<<setfill(' ')<<a[i] ; cout<<endl; for(int j=1;j<=9;j++) {for(int k=0;k<=9;k++) {if(k==0) cout<<setw(3)<<setfill(' ')<<a[j]; if (k<j&&k!=0) cout<<setw(3)<<setfill(' ')<<" "; if (k>=j) cout<<setw(3)<<setfill(' ')<<a[j]*a[k]; } cout<<endl; } }