返回列表 發帖

跑馬燈 (一)

本帖最後由 陳品肇 於 2018-11-24 17:33 編輯

設計一動畫,

□□□□□□□□□□
慢慢填滿如下圖
■■■■■■■■■■

□□■■■□□□□□
黑色方格不斷向右流動的感覺
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     for(int i=1; i<=65; i++)
  8.     {
  9.          if(i>=1 && i<=5)
  10.              cout<<"□□□□□□□□□□"<<endl;
  11.          if(i>=6 && i<=10)
  12.              cout<<"■□□□□□□□□□"<<endl;
  13.          if(i>=11 && i<=15)
  14.              cout<<"■■□□□□□□□□"<<endl;
  15.          if(i>=16 && i<=20)
  16.              cout<<"■■■□□□□□□□"<<endl;
  17.          if(i>=21 && i<=25)
  18.              cout<<"□■■■□□□□□□"<<endl;
  19.          if(i>=26 && i<=30)
  20.              cout<<"□□■■■□□□□□"<<endl;
  21.          if(i>=31 && i<=35)
  22.              cout<<"□□□■■■□□□□"<<endl;
  23.          if(i>=36 && i<=40)
  24.              cout<<"□□□□■■■□□□"<<endl;
  25.          if(i>=41 && i<=45)
  26.              cout<<"□□□□□■■■□□"<<endl;
  27.          if(i>=46 && i<=50)
  28.              cout<<"□□□□□□■■■□"<<endl;
  29.          if(i>=51 && i<=55)
  30.              cout<<"□□□□□□□■■■"<<endl;
  31.          if(i>=56 && i<=60)
  32.              cout<<"□□□□□□□□■■"<<endl;
  33.          if(i>=61 && i<=65)
  34.              cout<<"□□□□□□□□□■"<<endl;
  35.          system("cls");
  36.     }
  37.     goto re;
  38.     system("pause");
  39.     return 0;
  40. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

返回列表