//字符数组和字符串实例
#include<bits/stdc++.h>
using namespace std;
int main()
{
for(char letter ='a';letter <='z';letter+=2 )
{
cout<<setw(3)<<letter;//setw()函数setw(int n)是c++中在输出操作中使用的字段宽度设置,设置输出的域宽,n表示字段宽度。
//只对紧接着的输出有效,紧接着的输出结束后又变回默认的域宽。当后面紧跟着的输出字段长度小于n的时候,在该字段前面用空格补齐;
//当输出字段长度大于n时,全部整体输出。
}
cout<<endl;
for(char letter ='z';letter>='a';letter-=2)
{
cout<<setw(3)<<letter;
}
return 0;
}
输出示例
a c e g i k m o q s u w y
z x v t r p n l j h f d b
Process returned 0 (0x0) execution time : 0.036 s
Press any key to continue.