Monday, March 13, 2017

URI problem 1021 solution in C | (Banknotes and Coins)




To get the solution, click the link below:


https://codespathshala.com/uri-1021/

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include //stdio.h comment er karone gayeb hoye jay

    int main() {

    double n;
    int m, i, j, k;
    int note[12] = {10000,5000,2000,1000,500,200,100,50,25,10,5,1};
    int nota[12];

    scanf("%lf", &n);

    m = n * 100;

    for(i=0; i<12; i++){

    nota[i] = m / note[i];
    m %= note[i];
    }

    for(j=0; j<12; j++){

    if(j == 0){
    printf("NOTAS:\n");
    }
    if(j == 6){
    printf("MOEDAS:\n");
    }
    if(j < 6){
    printf("%d nota(s) de R$ %.2lf\n", nota[j], (float)note[j]/100);
    }
    else
    printf("%d moeda(s) de R$ %.2lf\n", nota[j], (float)note[j]/100);
    }

    return 0;
    }

    ReplyDelete
  3. #include
    int main()
    {
    double n,a1,b1,c1,d1,e1,f1,g1,h1;
    int a,b,c,d,e,f,h,i,z,j,k,l,m,i1,j1,k1,l1,m1,p;
    scanf("%lf",&n);
    printf("NOTAS:\n");
    a=n/100;
    printf("%d nota(s) de R$ 100.00\n",a);
    a1=n-(a*100);
    b=a1/50;
    printf("%d nota(s) de R$ 50.00\n",b);
    b1=a1-(b*50);
    c=b1/20;
    printf("%d nota(s) de R$ 20.00\n",c);
    c1=b1-(c*20);
    d=c1/10;
    printf("%d nota(s) de R$ 10.00\n",d);
    d1=c1-(d*10);
    e=d1/5;
    printf("%d nota(s) de R$ 5.00\n",e);
    e1=d1-(e*5);
    f=e1/2;
    printf("%d nota(s) de R$ 2.00\n",f);
    g1=e1-(f*2);

    printf("MOTAS:\n");
    z=g1*100;
    i=z/100;
    printf("%d moeda(s) de R$ 1.00\n",i);
    i1=z%100;
    j=i1/50;
    printf("%d moeda(s) de R$ 0.50\n",j);
    j1=i1%50;
    k=j1/25;
    printf("%d moeda(s) de R$ 0.25\n",k);
    k1=j1%25;
    l=k1/10;
    printf("%d moeda(s) de R$ 0.10\n",l);
    l1=k1%10;
    m=l1/5;
    printf("%d moeda(s) de R$ 0.05\n",m);
    m1=l1%5;
    p=m1;
    printf("%d moeda(s) de R$ 0.01\n",p);

    return 0;
    }
    //who did i make 5% mistake?

    ReplyDelete