矩阵
#include <iostream>
using namespace std;
int main()
{
const int m=2,n=3;
int a[m*n],b[m][n];
int x=1;
for(int i=0; i<6; i++,x++)
{
a[i]=x;
}
x=1;
for(int i=0; i<2; i++)
{
for(int j=0; j<3; j++,x++)
{
b[i][j]=x;
cout<<a[i*n+j]<<"\t"<<b[i][j]<<endl;
}
}
return 0;
}
月份转换:
#include <iostream>
using namespace std;
int main()
{
char month[12][10]= {"January","February","March","April","May","June","July","August","September","October","November","December"};
int m;
cin>>m;
if(m>0&&m<13)
{
cout<<month[m-1];
}
else
cout<<"The month is wrong";
return 0;
}