2 / 2
Nov 2018

Co mogę zrobić aby przyśpieszyć program bo już nie wiem

#include

using namespace std;

unsigned int silnia(unsigned int a)
{
if(a==1)return 1;
else return a*silnia(a-1);
}

void wypisz(unsigned int a)
{
unsigned int b = a%10;
unsigned int c = a%100;

if(c<10) c=0;
else if((c>=10) && (c<20)) c=1;
else if((c>=20) && (c<30)) c=2;
else if((c>=30) && (c<40)) c=3;
else if((c>=40) && (c<50)) c=4;
else if((c>=50) && (c<60)) c=5;
else if((c>=60) && (c<70)) c=6;
else if((c>=70) && (c<80)) c=7;
else if((c>=80) && (c<90)) c=8;
else if((c>=90) && (c<100)) c=9;

cout << c << ' ' << b << endl;

}

int main()
{
unsigned int a,b;

cin>>a;

for(int i=0;i<a;i++)
{
    cin>>b;
    b = silnia(b);
    wypisz(b);
}


return 0;

}

  • created

    Nov '18
  • last reply

    Nov '18
  • 1

    reply

  • 860

    views

  • 2

    users

  • 1

    link