返回列表 發帖

[作業] 跑馬燈 (四)

本帖最後由 tonyh 於 2015-6-27 11:36 編輯

使文字訊息在畫面上反覆地左右移動.



本帖隱藏的內容需要回復才可以瀏覽
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. clude<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     for(int i=1; i<=240; i+=2)   
  8.     {
  9.        if(i<=120)
  10.        {
  11.                  for(int j=0; j<=i; j++)   
  12.                 {
  13.                    cout<<"";
  14.                 }
  15.        }
  16.            
  17.        else
  18.        {
  19.             for(int j=0; j<=240-i; j++)   
  20.             {
  21.                 cout<<"";
  22.             }
  23.        }
  24.        cout<<"歡迎光臨";
  25.        system("cls");
  26.     }
  27.   
  28.     goto re;
  29.     system("pause");
  30.     return 0;
  31. }
複製代碼

TOP

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    re:
    for(int i=1; i<=80; i++)
    {
        if(i<=20)
            cout<<"歡";
        else if(i>21 && i<=40)
            cout<<"  迎";
        else if(i>41 && i<=60)
            cout<<"    光";
        else
            cout<<"      臨";
        system("cls");
    }
    for(int i=1; i<=80; i++)
    {
        if(i<=20)
            cout<<"歡";
        else if(i>21 && i<=40)
            cout<<"歡迎";
        else if(i>41 && i<=60)
            cout<<"歡迎光";
        else
            cout<<"歡迎光臨";
        system("cls");
    }
    for(int i=1; i<=140; i++)
    {
        if(i<=20)
            cout<<"";
        else if(i>21 && i<=40)
            cout<<"歡迎光臨";
        else if(i>41 && i<=60)
            cout<<"";
        else if(i>61 && i<=80)
            cout<<"歡迎光臨";
        else if(i>81 && i<=100)
            cout<<"";
        else if(i>101 && i<=120)
            cout<<"歡迎光臨";
        else
            cout<<"";
        system("cls");
    }
    goto re;        
    system("pause");
    return 0;
}

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     allre:
  7.     for(int i=1;i<=290;i++)
  8.     {
  9.          if(i>=1 and i<11)
  10.              cout<<" ";
  11.          if(i>=11 and i<21)         
  12.              cout<<"                                  ◆";
  13.          if(i>=21 and i<31)         
  14.              cout<<"                                ◇◆";
  15.          if(i>=31 and i<41)         
  16.              cout<<"                              ◆◇◆";
  17.          if(i>=41 and i<51)         
  18.              cout<<"                            ◇◆◇歡";
  19.          if(i>=51 and i<61)         
  20.              cout<<"                          ◆◇◆歡迎";
  21.          if(i>=61 and i<71)         
  22.              cout<<"                        ◇◆◇歡迎光";
  23.          if(i>=71 and i<81)         
  24.              cout<<"                      ◆◇◆歡迎光臨";
  25.          if(i>=81 and i<91)         
  26.              cout<<"                    ◇◆◇歡迎光臨◇";
  27.          if(i>=91 and i<101)         
  28.              cout<<"                  ◆◇◆歡迎光臨◆◇";
  29.          if(i>=101 and i<111)         
  30.              cout<<"                ◇◆◇歡迎光臨◇◆◇";
  31.          if(i>=111 and i<121)         
  32.              cout<<"              ◆◇◆歡迎光臨◆◇◆";
  33.          if(i>=121 and i<131)         
  34.              cout<<"            ◇◆◇歡迎光臨◇◆◇";
  35.          if(i>=131 and i<141)         
  36.              cout<<"          ◆◇◆歡迎光臨◆◇◆";
  37.          if(i>=141 and i<151)         
  38.              cout<<"        ◇◆◇歡迎光臨◇◆◇";
  39.          if(i>=151 and i<161)         
  40.              cout<<"      ◆◇◆歡迎光臨◆◇◆";
  41.          if(i>=161 and i<171)         
  42.              cout<<"    ◇◆◇歡迎光臨◇◆◇";
  43.          if(i>=171 and i<181)         
  44.              cout<<"  ◆◇◆歡迎光臨◆◇◆";
  45.          if(i>=181 and i<191)         
  46.              cout<<"◇◆◇歡迎光臨◇◆◇";
  47.          if(i>=191 and i<201)         
  48.              cout<<"◇◆歡迎光臨◆◇◆";
  49.          if(i>=201 and i<211)         
  50.              cout<<"◇歡迎光臨◇◆◇";
  51.          if(i>=211 and i<221)         
  52.              cout<<"歡迎光臨◆◇◆";
  53.          if(i>=221 and i<231)         
  54.              cout<<"迎光臨◇◆◇";
  55.          if(i>=231 and i<241)         
  56.              cout<<"光臨◆◇◆";
  57.          if(i>=241 and i<251)         
  58.              cout<<"臨◇◆◇";
  59.          if(i>=251 and i<261)         
  60.              cout<<"◆◇◆";
  61.          if(i>=261 and i<271)         
  62.              cout<<"◆◇";
  63.          if(i>=271 and i<281)         
  64.              cout<<"◆";
  65.          if(i>=281 and i<291)         
  66.              cout<<" ";
  67.          system("cls");
  68.     }
  69.     goto allre;
  70.     system("pause");
  71.     return 0;   
  72. }
複製代碼

TOP

好一點但還是很奇怪
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     allre:
  7.     for(int i=1;i<=150;i++)
  8.     {
  9.          if(i>=1 and i<11)         
  10.              cout<<"歡迎光臨";
  11.          if(i>=11 and i<121)
  12.              cout<<"  歡迎光臨";
  13.          if(i>=21 and i<31)
  14.              cout<<"    歡迎光臨";
  15.          if(i>=31 and i<41)
  16.              cout<<"      歡迎光臨";
  17.          if(i>=41 and i<51)
  18.              cout<<"        歡迎光臨";
  19.          if(i>=51 and i<61)
  20.              cout<<"          歡迎光臨";
  21.          if(i>=61 and i<71)
  22.              cout<<"            歡迎光臨";
  23.          if(i>=71 and i<81)
  24.              cout<<"              歡迎光臨";
  25.          if(i>=81 and i<91)
  26.              cout<<"            歡迎光臨";
  27.          if(i>=91 and i<101)
  28.              cout<<"          歡迎光臨";
  29.          if(i>=101 and i<111)
  30.              cout<<"        歡迎光臨";
  31.          if(i>=111 and i<121)
  32.              cout<<"      歡迎光臨";
  33.          if(i>=121 and i<131)
  34.              cout<<"    歡迎光臨";
  35.          if(i>=131 and i<141)
  36.              cout<<"  歡迎光臨";
  37.          if(i>=141 and i<151)
  38.              cout<<"歡迎光臨";
  39.          
  40.          system("cls");
  41.     }
  42.     goto allre;
  43.     system("pause");
  44.     return 0;   
  45. }
複製代碼

TOP

本帖最後由 謝瀞儀 於 2015-6-14 17:56 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     allre:
  7.     for(int i=1;i<=150;i++)
  8.     {
  9.          if(i>=1 and i<11)         
  10.              cout<<"歡迎光臨"<<endl;
  11.          if(i>=11 and i<21)
  12.              cout<<"  歡迎光臨"<<endl;
  13.          if(i>=21 and i<31)
  14.              cout<<"    歡迎光臨"<<endl;
  15.          if(i>=31 and i<41)
  16.              cout<<"      歡迎光臨"<<endl;
  17.          if(i>=41 and i<51)
  18.              cout<<"        歡迎光臨"<<endl;
  19.          if(i>=51 and i<61)
  20.              cout<<"          歡迎光臨"<<endl;
  21.          if(i>=61 and i<71)
  22.              cout<<"            歡迎光臨"<<endl;
  23.          if(i>=71 and i<81)
  24.              cout<<"              歡迎光臨"<<endl;
  25.          if(i>=81 and i<91)
  26.              cout<<"            歡迎光臨"<<endl;
  27.          if(i>=91 and i<101)
  28.              cout<<"          歡迎光臨"<<endl;
  29.          if(i>=101 and i<111)
  30.              cout<<"        歡迎光臨"<<endl;
  31.          if(i>=111 and i<121)
  32.              cout<<"      歡迎光臨"<<endl;
  33.          if(i>=121 and i<131)
  34.              cout<<"    歡迎光臨"<<endl;
  35.          if(i>=131 and i<141)
  36.              cout<<"  歡迎光臨"<<endl;
  37.          if(i>=141 and i<151)
  38.              cout<<"歡迎光臨"<<endl;
  39.          
  40.          system("cls");
  41.     }
  42.     goto allre;
  43.     system("pause");
  44.     return 0;   
  45. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     allre:
  7.     for(int i=1;i<=270;i++)
  8.     {
  9.          if(i>=1 and i<11)
  10.              cout<<"◇"<<endl;
  11.          if(i>=11 and i<21)
  12.              cout<<"◇◆"<<endl;
  13.          if(i>=21 and i<31)
  14.              cout<<"◇◆◇"<<endl;
  15.          if(i>=31 and i<41)
  16.              cout<<"◇◆◇歡"<<endl;
  17.          if(i>=41 and i<51)
  18.              cout<<"◇◆◇歡迎"<<endl;
  19.          if(i>=51 and i<61)
  20.              cout<<"◇◆◇歡迎光"<<endl;
  21.          if(i>=61 and i<71)
  22.              cout<<"◇◆◇歡迎光臨"<<endl;
  23.          if(i>=71 and i<81)
  24.              cout<<"◇◆◇歡迎光臨◇"<<endl;
  25.          if(i>=81 and i<91)
  26.              cout<<"◇◆◇歡迎光臨◇◆"<<endl;
  27.          if(i>=91 and i<101)
  28.              cout<<"◇◆◇歡迎光臨◇◆◇"<<endl;
  29.          if(i>=101 and i<111)
  30.              cout<<"◆◇◆歡迎光臨◆◇◆"<<endl;
  31.          if(i>=111 and i<121)
  32.              cout<<"  ◇◆◇歡迎光臨◇◆◇"<<endl;
  33.          if(i>=121 and i<131)
  34.              cout<<"    ◆◇◆歡迎光臨◆◇◆"<<endl;
  35.          if(i>=131 and i<141)
  36.              cout<<"      ◇◆◇歡迎光臨◇◆◇"<<endl;
  37.          if(i>=141 and i<151)
  38.              cout<<"        ◆◇◆歡迎光臨◆◇◆"<<endl;
  39.          if(i>=151 and i<161)
  40.              cout<<"          ◇◆◇歡迎光臨◇◆◇"<<endl;
  41.          if(i>=161 and i<171)
  42.              cout<<"            ◆◇◆歡迎光臨◆◇◆"<<endl;
  43.          if(i>=171 and i<181)
  44.              cout<<"              ◇◆◇歡迎光臨◇◆◇"<<endl;
  45.          if(i>=181 and i<191)
  46.              cout<<"                ◆◇◆歡迎光臨◆◇◆"<<endl;
  47.          if(i>=191 and i<201)
  48.              cout<<"              ◇◆◇歡迎光臨◇◆◇"<<endl;
  49.          if(i>=201 and i<211)
  50.              cout<<"            ◆◇◆歡迎光臨◆◇◆"<<endl;
  51.          if(i>=211 and i<221)
  52.              cout<<"          ◇◆◇歡迎光臨◇◆◇"<<endl;
  53.          if(i>=221 and i<231)
  54.              cout<<"        ◆◇◆歡迎光臨◆◇◆"<<endl;
  55.          if(i>=231 and i<241)
  56.              cout<<"      ◇◆◇歡迎光臨◇◆◇"<<endl;
  57.          if(i>=241 and i<251)
  58.              cout<<"    ◆◇◆歡迎光臨◆◇◆"<<endl;
  59.          if(i>=251 and i<261)
  60.              cout<<"  ◇◆◇歡迎光臨◇◆◇"<<endl;
  61.          if(i>=261 and i<271)
  62.              cout<<"◆◇◆歡迎光臨◆◇◆"<<endl;
  63.          
  64.          system("cls");
  65.     }
  66.    
  67.             
  68.    
  69.     goto allre;
  70.    
  71.    
  72.    
  73.     system("pause");
  74.     return 0;   
  75. }
複製代碼

TOP

本帖最後由 李知易 於 2015-6-27 11:48 編輯
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     for(int i=1;i<=240;i++)
  8.     {
  9.           if(i<=120)
  10.           {
  11.               for(int j=0;j<=i;j+=2)
  12.                   cout<<" ";
  13.           }else
  14.           {
  15.                for(int j=0;j<=240-i;j+=2)
  16.                   cout<<" ";
  17.           }  
  18.           cout<<"新年快樂";
  19.           system("cls");      
  20.     }
  21.     goto re;        
  22.    system("pause");
  23.    return 0;
  24. }
複製代碼

TOP

返回列表