运行 ❯
获得
您自己的
网站
×
更改方位
更改主题,明暗
转到 Spaces
#include <iostream> #include <string> using namespace std; int main() { struct { string brand; string model; int year; } myCar1, myCar2; // We can add variables by separating them with a comma here // Put data into the first structure myCar1.brand = "BMW"; myCar1.model = "X5"; myCar1.year = 1999; // Put data into the second structure 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