瞎研究.. #include<iostream> #include<windows.h> using namespace std; struct LIST { char str[3]; LIST *up,*next; }; class LED { public: LED(); void rightmove(int speed,int loop=-1); void leftmove(int speed,int loop=-1); private: LIST *head; int lenth; }; LED::LED() { lenth=0; char str,flag=0; LIST *f,*p=head=new LIST; cin>>head->str[0]; if(head->str[0]>=0&&head->str[0]<=255) { head->str[1]='/0'; } else { cin>>head->str[1]; head->str[2]='/0'; } p->next=head; lenth++;; while((str=getchar())!='/n') { f=new LIST; f->up=p; p->next=f; p=f; lenth++; p->str[0]=str; if(p->str[0]>=0&&p->str[0]<=255) { p->str[1]='/0'; } else { cin>>p->str[1]; p->str[2]='/0'; } } p->next=head; head->up=p; } void LED::rightmove(int speed,int loop) { LIST *p=head; while(loop) { system("cls"); for(int i=0;i<lenth;i++,p=p->next) cout<<p->str; p=p->up; loop--; Sleep(speed); } } void LED::leftmove(int speed,int loop) { LIST *p=head; while(loop) { system("cls"); for(int i=0;i<lenth;i++,p=p->next) cout<<p->str; p=p->next; loop--; Sleep(speed); } } int main() { LED s; s.rightmove(500); return 0; }