求各位大神解答c++的一道题,希望帮忙改改,谢谢指教

设计一个程序,按表格形式输出实际生活中的多行数据信息,要求同一列数据上下对齐。

例如:有以下省市的面积和人口信息,请定义结构体类型City,包括省名、面积、人口,输入以下的数据值,再按表格形式输出所有数据。


Province Area(km2) Pop.(10K)

Anhui 139600.00 6461.00

Beijing 16410.54 1180.70

Chongqing 82400.00 3144.23

Shanghai 6340.50 1360.26

Zhejiang 101800.00 4894.00

#include
using namespace std;
#include
struct City
{
char province[20];
double area;
double pop;
};
void display(struct City *);
int main()
{

struct City city[5]={
{"Anhui",139600.00,6461.00},
{"Beijing",16410.54,1180.70},
{"Chongqing",82400.00,3144.23},
{"Shanghai",6340.50,1360.26},
{"Zhejiang",101800.00,4894.00}
};
display(&city);
return 0;

}
void display(struct City *C)

{
cout<<"------------------------------------"< cout cout for(int i=0;i {
coutprovince;
cout<area;
cout<<" "<pop;
*C++;
i++;
}
}

// Q1055336.cpp : Defines the entry point for the console application.
//


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

struct City
{
    char province[20];
    double area;
    double pop; 
};
void display(struct City *, int n);
int main()
{
    struct City city[5]={
        {"Anhui",139600.00,6461.00},
        {"Beijing",16410.54,1180.70},
        {"Chongqing",82400.00,3144.23},
        {"Shanghai",6340.50,1360.26},
        {"Zhejiang",101800.00,4894.00}
    };
    display(city, 5);
    return 0;
}
void display(struct City *C, int n)
{
    cout<<"---------------------------------------"<< endl;
    cout << setw(1) << "|" << setw(15) << "province" << "|";
    cout << setw(10) << "area" << "|";
    cout << setw(10) << "pop" << "|";
    cout << endl;
    cout<<"---------------------------------------"<< endl;
    for(int i = 0;i < n; i++) {
        cout << setw(1) << "|" << setw(15) << C[i].province << "|";
        cout << setw(10) << C[i].area << "|";
        cout << setw(10) << C[i].pop << "|";
        cout << endl;
    }
    cout<<"---------------------------------------"<< endl;
}

运行结果

---------------------------------------
|       province|      area|       pop|
---------------------------------------
|          Anhui|    139600|      6461|
|        Beijing|   16410.5|    1180.7|
|      Chongqing|     82400|   3144.23|
|       Shanghai|    6340.5|   1360.26|
|       Zhejiang|    101800|      4894|
---------------------------------------
Press any key to continue . . .

问题解决的话,请点采纳