A multiple of 3, to give you a positive integer, you judge that it is not a multiple of 3? T has a data input (T less than 50), representing data for each data group T, an integer n (n is greater than 1 less than 10 th 1000) Note that the data range

A multiple of three
gives you a positive integer, you determine if it is a multiple of 3?

Input format:
input data has a T (T <= 50), representatives of T sets of data
for each set of data, an integer n-(. 1 <= n-<10 =
1000
) Note that the range of the data
output format:
For each set data output line "YES" or "nO" (without the quotes), or representative of the number is not a multiple of three
input sample:
here a given set of inputs. For example:
2
33332
123
Output Sample:
In the given here corresponding output. For example:
NO
YES

# include<stdio.h>
# include<string.h>
int main()
{
	int m,n,i,j,k=0;
	char ch[10001];
	scanf("%d",&m);
	for(n=0;n<m;n++)
	{
		scanf("%s",ch);
		i=strlen(ch);
		for(j=0;j<i;j++)
		{
			k+=(ch[j]-'0');
		}
		if(k%3==0)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		k=0;
	}
	return 0;
}

Note this Title: Characteristics of a multiple of 3, the number on each digit of the sum is a multiple of 3.

Published 123 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/Du798566/article/details/104779948