返回列表 發帖
本帖最後由 邱品惟 於 2023-8-11 17:56 編輯

回復 2# 鄭繼威
  1. #include<iostream>
  2. #include<ctime>
  3. using namespace std;
  4. int main()
  5. {
  6.         srand(time(NULL));
  7.         for(int j=1;j<=20;j++)
  8.         {
  9.            int n[6];
  10.            for(int i=0; i<=5; i++)
  11.            {
  12.               n[i]=rand()%30-10;
  13.               if(n[i]%2!=0)
  14.               {
  15.                   i--;
  16.               }   
  17.               for(int k=0;k<=i-1 ;k++)
  18.                   {
  19.                       if(n[i]==n[k])
  20.                       {
  21.                           i--;      
  22.                       }
  23.                   }
  24.               
  25.             }
  26.             for(int i=0; i<=5; i++)
  27.             {
  28.                 cout<<n[i]<<" ";
  29.             }
  30.             if(j%2==0)
  31.                 _sleep(200);
  32.             cout<<endl;
  33.            
  34.         }
  35.       
  36.     system("pause");   
  37.     return 0;
  38. }
複製代碼

TOP

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int b,c,d=1;;
  6.     for(int a=1;a<=5;a=a+1)
  7.     {
  8.         int sum=a*2-1;
  9.         for(b=4;b>=a;b=b-1)
  10.         {
  11.              cout<<" ";
  12.         }
  13.         b=4;
  14.         for(c=1;c<=sum;c=c+1)
  15.         {
  16.             cout<<b+d;        
  17.         }
  18.         d=d-1;
  19.         cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼
回復 3# 鄭繼威

TOP

  1. #include<iostream>
  2. #include<ctime>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a;
  7.     cout<<"請輸入西元年";
  8.     cin>>a;
  9.     if(a%12==4)
  10.         cout<<"鼠年"<<endl;
  11.     else if(a%12==5)
  12.         cout<<"牛年"<<endl;
  13.     else if(a%12==6)
  14.         cout<<"虎年"<<endl;
  15.     else if(a%12==7)
  16.         cout<<"兔年"<<endl;
  17.     else if(a%12==8)
  18.         cout<<"龍年"<<endl;
  19.     else if(a%12==9)
  20.         cout<<"蛇年"<<endl;
  21.     else if(a%12==10)
  22.         cout<<"馬年"<<endl;
  23.     else if(a%12==11)
  24.         cout<<"羊年"<<endl;
  25.     else if(a%12==0)
  26.         cout<<"猴年"<<endl;
  27.     else if(a%12==1)
  28.         cout<<"雞年"<<endl;
  29.     else if(a%12==2)
  30.         cout<<"狗年"<<endl;
  31.     else if(a%12==3)
  32.         cout<<"豬年"<<endl;
  33.     system("pause");   
  34.     return 0;
  35. }
複製代碼
回復 4# 鄭繼威

TOP

返回列表