#include<stdio.h>
#include<math.h>
int main()
{
long test,xx=1;
while(~scanf("%ld",&test))
{
long i,s1,s=0,a,minus=0,d=0,p=0,p1=0,d1=0,d2=0,temp=0,g=0,count=0,count1=0,k=0,k1=0,k2=0,test1=0,b=0,b1=0,b2=0,b3=0,count2=0;
if(test==0)
break;
for(i=0; i<test; i++)
{
scanf("%ld",&a);
s=s+a;
}
if(s<0)
minus=1;
d=s/(double)test;
p=s-d*test;
printf("Case %ld:\n",xx++);
if(p==0)
{
if(d>=0)
printf("%ld\n",d);
else if(d<0)
printf("- %ld\n",d*(-1));
}
else
{
p=fabs(p);
p1=p;
test1=test;
d1=d;
d2=fabs(d);
while(test!=0)
{
temp=p%test;
p=test;
test=temp;
}
b=p1/p;
b1=test1/p;
b2=b1;
b3=b;
while(b1>9)
{
g=b1%10;
count++;
b1=b1/10;
}
count2=0;
while(d2>9)
{
g=d2%10;
count1++;
d2=d2/10;
}
while(b3>9)
{
g=b3%10;
count2++;
b3=b3/10;
}
k=k+count;
if(minus==1)
{
k=k+2;
}
if(d1!=0)
{
k=k+count1+1;
}
for(i=0; i<k-count2; i++)
printf(" ");
printf("%ld\n",b);
if(minus==1)
{
printf("- ");
if(d1<0)
{
d1=fabs(d1);
printf("%ld",d1);
}
}
else
{
if(d1>0)
printf("%ld",d1);
}
for(i=0; i<count+1; i++)
printf("-");
printf("\n");
k=0;
if(minus==1)
k=k+2;
if(d1!=0)
{
k=k+count1+1;
}
for(i=0; i<k; i++)
printf(" ");
printf("%ld\n",b2);
}
}
return 0;
}
#include<math.h>
int main()
{
long test,xx=1;
while(~scanf("%ld",&test))
{
long i,s1,s=0,a,minus=0,d=0,p=0,p1=0,d1=0,d2=0,temp=0,g=0,count=0,count1=0,k=0,k1=0,k2=0,test1=0,b=0,b1=0,b2=0,b3=0,count2=0;
if(test==0)
break;
for(i=0; i<test; i++)
{
scanf("%ld",&a);
s=s+a;
}
if(s<0)
minus=1;
d=s/(double)test;
p=s-d*test;
printf("Case %ld:\n",xx++);
if(p==0)
{
if(d>=0)
printf("%ld\n",d);
else if(d<0)
printf("- %ld\n",d*(-1));
}
else
{
p=fabs(p);
p1=p;
test1=test;
d1=d;
d2=fabs(d);
while(test!=0)
{
temp=p%test;
p=test;
test=temp;
}
b=p1/p;
b1=test1/p;
b2=b1;
b3=b;
while(b1>9)
{
g=b1%10;
count++;
b1=b1/10;
}
count2=0;
while(d2>9)
{
g=d2%10;
count1++;
d2=d2/10;
}
while(b3>9)
{
g=b3%10;
count2++;
b3=b3/10;
}
k=k+count;
if(minus==1)
{
k=k+2;
}
if(d1!=0)
{
k=k+count1+1;
}
for(i=0; i<k-count2; i++)
printf(" ");
printf("%ld\n",b);
if(minus==1)
{
printf("- ");
if(d1<0)
{
d1=fabs(d1);
printf("%ld",d1);
}
}
else
{
if(d1>0)
printf("%ld",d1);
}
for(i=0; i<count+1; i++)
printf("-");
printf("\n");
k=0;
if(minus==1)
k=k+2;
if(d1!=0)
{
k=k+count1+1;
}
for(i=0; i<k; i++)
printf(" ");
printf("%ld\n",b2);
}
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন