|
|
вернуться в форумLOOK AT THIS IT'S TRUE #include <iostream> using namespace std; int a,b,i,d,j=2,e=1; char c[25]; int mod(int d,int f){ if(d<=f){return d;} else{return mod(d-f,f);} } int fac(int g,int h){ if(g==d){return d;} else{return e*g*fac(g-h,h);} } int main(){ gets(c); a=c[0]-48; if(c[1]=='0'){ a=10; j=3; } for (i=j;c[i]=='!';i++){ b++; } d=mod(a,b); cout<<fac(a,b); return 0;} Re: LOOK AT THIS IT'S TRUE #include <iostream> using namespace std; int count (char u[],char p) { int k=0; for (int i=0; i<strlen(u); i++) if (u[i]==p) k++; return k; } int main () { int N,k=0,sum; cin>>N; char S[20],t='!'; gets(S); sum=N; while (N>=count(S,t)) { N-=count(S,t); if (N) sum*=N; } cout<<sum; return 0; }
Another variation ))) Edited by author 13.09.2008 23:35 |
|
|