Wednesday 8 June 2016

Solution of URI 2060 :: Bino's Challenge


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int num, i, a, cnt2=0, cnt3=0, cnt4=0, cnt5=0;
    scanf("%d", &num);
    for(i=0; i<num; i++)
    {
        scanf("%d", &a);
        if(a % 2 == 0) cnt2++;
        if(a % 3 == 0) cnt3++;
        if(a % 4 == 0) cnt4++;
        if(a % 5 == 0) cnt5++;
    }
    printf("%d Multiplo(s) de 2\n", cnt2);
    printf("%d Multiplo(s) de 3\n", cnt3);
    printf("%d Multiplo(s) de 4\n", cnt4);
    printf("%d Multiplo(s) de 5\n", cnt5);
    return 0;
}

1 comment:

  1. your way to do this is so complicate that i can't do it.

    ReplyDelete

Note: only a member of this blog may post a comment.