ACM (UVa) : 11332



#include <stdio.h>

int main ()
{
	long N, Sum;

	while (scanf ("%ld", &N)) {

		if (N==0)
			break;
again:
		Sum = 0;
		while (N) {
			Sum += (N % 10);
			N/=10;
		}

		if (Sum/10==0)
			printf("%ld\n", Sum);
		else {
			N = Sum;
			goto again;
		}
	}

	return 0;
}

Advertisements

One thought on “ACM (UVa) : 11332

  1. #include
    int func(long long n)
    {

    int i=0;

    while(n)
    {
    i+=n%10;
    n/=10;
    }
    if(i0))
    {

    func(n);
    }
    return 0;
    }
    What’s happen in this program still wrong ans.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s