关于Python和c++

img

img


一个是Python类型的,一个是c++类型的题目,Python是排序,c++是派生和继承之类的问题

python是什么题目。。。
固定长度输出通用格式如下:

cout << right << setw(width) << data << endl;

完整代码:

#include <iostream>
#include <iomanip>
using namespace std;

void outputData(char* data, int width = 10)
{
    cout << right << setw(width) << data << endl;
}

void outputData(int  data, int width = 10)
{
    cout << right << setw(width) << data << endl;
}

void outputData(double data, int width = 10)
{
    cout << right << setw(width) << fixed << setprecision(2) << data << endl;
}

int main()
{
    int a = 10;
    double b = 2333.34333;
    char* p = new char[100];
    strcpy_s(p,100,"this is a test string, you know?"); //长度大于10的字符串

    outputData(a);
    outputData(b);
    outputData(p);

    strcpy_s(p, 100, "white"); //长度不足10的字符串
    outputData(p);

    return 0;
}

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632