#9785: c++解答 (又沒規定要怎麼解


kerry970176 (AceIn)

學校 : 臺北市私立延平高級中學
編號 : 42345
來源 : [36.225.144.210]
最後登入時間 :
2023-02-16 15:15:16
d487. Order's computation process -- 學姊 | From: [203.72.178.252] | 發表日期 : 2015-04-16 17:39

#include<iostream>
using namespace std;
main()
{
int n;while(cin>>n){
if (n==0)cout<<"0! = 1 = 1"<<endl;
else if (n==1)cout<<"1! = 1 = 1"<<endl;
else if (n==2)cout<<"2! = 2 * 1 = 2"<<endl;
else if (n==3)cout<<"3! = 3 * 2 * 1 = 6"<<endl;
else if (n==4)cout<<"4! = 4 * 3 * 2 * 1 = 24"<<endl;
else if (n==5)cout<<"5! = 5 * 4 * 3 * 2 * 1 = 120"<<endl;
else if (n==6)cout<<"6! = 6 * 5 * 4 * 3 * 2 * 1 = 720"<<endl;
else if (n==7)cout<<"7! = 7 * 6 * 5 * 4 * 3 * 2 * 1 = 5040"<<endl;
else if (n==8)cout<<"8! = 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 40320"<<endl;
else if (n==9)cout<<"9! = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880"<<endl;
else if (n==10)cout<<"10! = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 3628800"<<endl;
}
}
 
ZeroJudge Forum