自考新教材-p286

源程序:

//

//  main.cpp

//  p286

//

//  Created by duanqibo on 2020/1/27.

//  Copyright © 2020年 duanqibo. All rights reserved.

//

 

//程序7-7

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

    string s1,s2;

    cin>>setw(5)>>s1>>setw(3)>>s2;      //设置输入的字符串格式(长度)

    cout<<"s1="<<s1<<", s2="<<s2<<endl;

    return 0;

}

 运行结果:

posted @ 2020-01-27 14:34  bobo哥  阅读(205)  评论(0编辑  收藏  举报