运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往空间
#include <iostream> #include <string> using namespace std; // Declare a structure named "car" struct car { string brand; string model; int year; }; int main() { // Create a car structure and store it in myCar1; car myCar1; myCar1.brand = "BMW"; myCar1.model = "X5"; myCar1.year = 1999; // Create another car structure and store it in myCar2; car myCar2; myCar2.brand = "Ford"; myCar2.model = "Mustang"; myCar2.year = 1969; // Print the structure members cout << myCar1.brand << " " << myCar1.model << " " << myCar1.year << "\n"; cout << myCar2.brand << " " << myCar2.model << " " << myCar2.year << "\n"; return 0; }
宝马 X5 1999
福特野马 1969