效果:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
//运行环境 dev c++ 5.9.2 #include <iostream> #include <windows.h> //Sleep函数调用的头文件 #include <mmsystem.h> //媒体控制函数的头文件 //在VC2008和VC6.0环境中从此头文件 #pragma comment(lib, "winmm.lib") using namespace std; class automobile { private: char type[20]; char color[20]; float price; int carry_weight; int carry_customer; public: void set_date(char *t, char *c, float pri, int cw, int cc); //初始化或修改数据成员 void movecar(int l, int k); void horming(int num); void downcar(int l); void play_mp3(char *ps); char *show_type() { return type; } }; void automobile::set_date(char *t, char *c, float pri, int cw, int cc) { strcpy(type, t); strcpy(color, c); price = pri; carry_weight = cw; carry_customer = cc; } void automobile::movecar(int l, int k) { cout<<" "<<type<<"水平直线运动:"<<endl; for(int i=0; i<l; i++) { cout<<' '<<"o-o"; Sleep(1000/k); cout<<""; } } void automobile::downcar(int l) { //垂直下降运动 cout<<" "<<type; for(int i=0; i<l; i++) { cout<<"o_o"; Sleep(500); cout<<""<<" "; cout<<endl; } } void automobile::horming(int num) { for(int i=0; i<num; i++) { cout<<type; cout<<"