2011年4月24日 星期日

分享

高中生程式解題系統 a058: MOD3


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int main(void) 
{
    
    int length;
    int i;
    int temp[100];
    int k_0,k_1,k_2;
    
    while(scanf("%d",&length)!=EOF)
    {
        k_0 = k_1 = k_2 = 0;

        for(i=0;i<length;i++)
            scanf("%d",&temp[i]);

        for(i=0;i<length;i++)
        {
            if(temp[i] % 3 == 0)
                k_0++;
            else if(temp[i] % 3 == 1)
                k_1++;
            else if(temp[i] % 3 == 2)
                k_2++;
        }

        printf("%d %d %d\n",k_0,k_1,k_2);

        
    }
    
    return 0;
}

沒有留言:

張貼留言