#include
int k;
int sumOfFactor(int n)
{ int i,s=1;
for(i=2; i*i if(n%i==0)s+=i+n/i; if(i*i==n)s+=i; return s; } int friendNum(int n) { k=sumOfFactor(n); return k==sumOfFactor(n)&&n==sumOfFactor(k); } int main() { int n; scanf("%d",&n); if(friendNum(n)) printf("Find the friendly number of %d is %d.\n",n,k); else printf("There is no friendly number of %d.\n",n); return 0; }
#include
int main() {
int i,score,min,max,sum=0;
for(i=0; i<7; i++) {
printf("Input %d: ",i);
scanf("%d",&score);
if(i==0)
min=max=score;
else {
if(score>max) max=score;
if(score}
sum+=score;
}
printf("Sum=%d Min=%d Max=%d AVG=%.2f",sum,min,max,1.0*(sum-max-min)/5);
}
假设满分10.0分
int calc(float *num, int count, float *result) {
if (count <= 2) {
return -1;
}
float min = 10.0;
float max = 0.0;
float sum = 0.0;
for (int i=0; i
min = num[i];
} else if (num[i] > max) {
max = num[i];
} else {
sum += num[i];
}
}
*result = sum / (count - 2);
return 0;
}