#include <stdio.h>
#include <conio.h>
int main()
{
long int sum1=0,sum=0,n,ts;
scanf("%d",&n);
int a[n];
for(long int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
ts=sum/n;
if(sum%n!=0)
printf("The numbers you entered is wrong.");
char ch;
ch=getche();
while(ch!=48)
continue;
for(long int j=0;j<n;j++)
if(a[j]>ts)
sum1+=(a[j]-ts);
printf("\nSet #1\n");
printf("The minimum of moves is %d",sum1);
getch();
return 0;
}
#include <stdio.h>
#include <conio.h>
int main()
{
long int sum1=0,sum=0,n,ts;
scanf("%d",&n);
int a[n];
for(long int i=0;i<n;i++)
{
scanf("%d",&a[I]);
sum+=a[I];
}
ts=sum/n;
if(sum%n!=0)
printf("The numbers you entered is wrong.");
char ch;
ch=getche();
while(ch!=48)
continue;
for(long int j=0;j<n;j++)
if(a[j]>ts)
sum1+=(a[j]-ts);
printf("\nSet #1\n");
printf("The minimum of moves is %d",sum1);
getch();
return 0;
}
3
1 2 3
set #1
The minimum of moves is 1
5
1 2 3 4 5
set #2
The minimum of moves is 3
0(اينجا از برنامه خارج مي شه)
#include <stdio.h>
#include <conio.h>
int main()
{
long int sum1=0,sum=0,n,ts;
scanf("%d",&n);
int a[n];
for(long int i=0;i<n;i++)
{
scanf("%d",&a[I]);
sum+=a[I];
}
ts=sum/n;
if(sum%n!=0)
printf("The numbers you entered is wrong.");
char ch;
ch=getche();
while(ch!=48)
continue;
for(long int j=0;j<n;j++)
if(a[j]>ts)
sum1+=(a[j]-ts);
printf("\nSet #1\n");
printf("The minimum of moves is %d",sum1);
getch();
return 0;
}
3
1 2 3
set #1
The minimum of moves is 1
5
1 2 3 4 5
set #2
The minimum of moves is 3
0(اينجا از برنامه خارج مي شه)
#include <stdio.h>
#include <conio.h>
int main()
{
int adad=0;
start:
int b,c,sum=0,miangin,tedad=0,n;
scanf("%d",&n);
int a[n];
adad++;
if(n==0) goto end;
for(b=1;b<=n;b++){
scanf("%d",&a[b]);
sum+=a[b];}
miangin=sum/n;
for(b=1;b<=n;b++){
if(a[b]<miangin)
tedad+=(miangin-a[b]);}
printf("Set #%d\n",adad);
printf("The minimum number of moves is %d.\n",tedad);
goto start;
getch();
end:
return 0;
}
#include <stdio.h>
#include <conio.h>
#include <math.h>
long int isprime(long int k)
{
int flag=1;
for(int i=2;i<=sqrt(k)&&flag==1;i++)
if(k%i==0)
flag=0;
return flag;
}
int t(int k)
{
int flag=1;
for(int i=2;(i<=k)&&(flag==1);i++)
if(k%i==0&&isprime(i)==1&&i%10!=3)
flag=0;
return flag;
}
int main()
{
start:
long int n;
scanf("%d",&n);
if(n==-1)
goto end;
if(t(n)==0)
printf("no");
for(int i=3;i<=n;i++)
{
if(i==n&&t(i)==1)
printf("yes");
}
goto start;
end:
getch();
return 0;
}
#include <stdio.h>
#include <conio.h>
#include <math.h>
long int isprime(long int k)
{
int flag=1;
for(int i=2;i<=sqrt(k)&&flag==1;i++)
if(k%i==0)
flag=0;
return flag;
}
int main()
{
start:
long int n,a;
scanf("%d",&n);
a=n;
if(n==1) {printf("%d NO\n",a); goto start;} if(n==-1) goto end2;
for(long int i=2;i<=n;i++)
if(n%i==0 && isprime(i)==1)
while(n%i==0)
{
n/=i;
if(i%10 != 3)
{printf("%d NO\n",a); goto start;}
}
printf("%d YES\n",a);
goto start;
getch();
end2:
return 0;
}
#include <stdio.h>
#include <conio.h>
long int chart(int m,int n)
{
long int h=((((m*(m-1))/2)+(1))+(n-1));
return h;
}
int main()
{
int t;
scanf("%d",&t);
start:
int a[100],u=(2*t);
int b[U];
int z=0;
for(int i=1;i<=t;i++)
{
int x,y;
printf("Enter number x , y :");
scanf("%d%d",&x,&y);
a[z]=x;
a[z+1]=y;
z++;
z++;
}
for(int r=0;r<u;r+=2)
if(a[r]>1000||a[r+1]>1000)
goto end;
for(int l=0;l<=(2*t);l+=2)
{
if(a[l]>=a[l+1])
printf("\n%d",chart(a[l],a[l+1]));
else
printf("\nNo Solution");
}
end:
getch();
return 0;
}
#include <conio.h>
#include <stdio.h>
int main()
{
int x,y,z,b,c,t;
scanf("%d",&t);
for(c=1;c<=t;c++){
printf("please input y x:\t");
scanf("%d%d",&x,&y);
if (x>y)
printf("no number!\n");
if (x<=y){
z=(y*(y+1))/2;
b=z-(y-x);
printf("%d\n",b);}}
getch();
return 0;
}