28 条题解
-
39
兄弟们,我又又又又来写题了奥! 今天这题有点意思,我写了比较长的一个代码,请大家见谅,我也总结出了几点大家要掌握的
- 这个变量要用数组来存放
- 最后算出的平均值要用多位小数点型 double 来存放
- 记住,有几个苹果最小就删掉几个,还要用变量 s 来存放总共记载的苹果数量
- 最后的输出格式可以参考 Level 3 【入门】已知一个圆的半径,求解该圆的面积和周长这题我的题解保留小数位数即可。
闲话不多说(都说了这么多了),上代码 😄 ~
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, a[1000], min = 99999; double sum = 0; cin >> n; for (int i=1;i<=n;i++) { cin >> a[i]; if (min > a[i]) min = a[i]; } for (int i=1;i<=n;i++) { if (a[i] != min) { sum += a[i]; s += 1; } } printf("%.1lf", sum / s); return 0; }
-
22
思路就是首先求出最小值 求出以后求和的时候只求大于最小值的 并且还要统计对应的个数 最后求平均值即可
double n,a[105],sum=0,minn=10000,ans;//求最小值的时候初始设立一个极大值 cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; if(a[i]<=minn) { minn=a[i];//如果a[i]<=minn,说明a[i]可以当最小值,此时更新minn //循环结束后就可以找到最小的那个a[i]并赋值给minn方便我们使用 } } for(int i=0;i<n;i++) { if(a[i]>minn) { sum+=a[i];//求和的时候不包括那些最小值 ans++;//统计大于最小值的苹果个数 } } cout<<fixed<<setprecision(1)<<sum/ans;
-
10
上代码!!!
#include <bits/stdc++.h> using namespace std; int main(){ int n,a[99],minn = 99999999,minnnum = 0,sum = 0; cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i]; minn = min(minn,a[i]); } for(int i = 1;i <= n;i++){ if(a[i] != minn){ minnnum++; sum += a[i]; } } cout << fixed << setprecision(1) << sum*1.0 / minnnum; return 0; }
先点赞,再抱走哦
-
9
这一道题说实话挺简单的,请看题解(已AC,请放心食用😏)
#include <iostream> #include <iomanip> using namespace std; int main() { int n, a[10000], minn = 1145114; double sum = 0; cin >> n; int num = n; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; if (a[i] < minn) { minn = a[i]; } } for (int i = 0; i < n; i++) { if (a[i] == minn) { sum -= a[i]; num -= 1; } } double avg = sum / num; cout << fixed << setprecision(1) << avg << endl; return 0; }
哎,先别走,制作不易,点个赞再走呗😎
如果你已经点上了赞,我要先跟你说一声“谢谢”,然后再说一声“再见”! ヾ( ̄▽ ̄)Bye~ Bye~
-
2
#include<bits/stdc++.h> using namespace std; int main() { int b[23455],k=234541,sum=0,m=0; double a,n; cin>>a; for(int i=1;i<=a;i++) { cin>>b[i]; } for(int i=1;i<=a;i++) { if(b[i]<k) { k=b[i]; } } for(int i=1;i<=a;i++) { if(b[i]==k) { m+=1; } else { sum+=b[i]; } } n=sum/(a-m); cout<<fixed<<setprecision(1)<<n; return 0; }
-
2
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, s = 0, a[1000], min = 99999;
double sum = 0;
cin >> n;
for (int i=1;i<=n;i++)
{
cin >> a[i];
if (min > a[i]) min = a[i];
}
for (int i=1;i<=n;i++)
{
if (a[i] != min)
{
sum += a[i];
s += 1;
}
}
printf("%.1lf", sum / s);
return 0;
}
点个赞吧!已AC✔~ 可复制❄~
-
2
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, a[1000], min = 99999; double sum = 0; cin >> n; for (int i=1;i<=n;i++) { cin >> a[i]; if (min > a[i]) min = a[i]; } for (int i=1;i<=n;i++) { if (a[i] != min) { sum += a[i]; s += 1; } } printf("%.1lf", sum / s); return 0; } 你干嘛哈哈诶有!
-
2
对我来说,好像有那么亿点难
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, a[1000], min = 99999; double sum = 0; cin >> n; for (int i=1;i<=n;i++){ cin >> a[i]; if (min > a[i]) min = a[i]; } for (int i=1;i<=n;i++){ if (a[i] != min) { sum += a[i]; s += 1; } } printf("%.1lf", sum / s); return 0; }
求赞❤️
-
2
#include <bits/stdc++.h> using namespace std; int main() { int a[105],b = 10000,sum = 0,n,c,num = 0; cin >> n; for (int i = 1;i <= n;i++) { cin >> c; a[i] = c; if (a[i] <= b) { b = a[i]; } } for (int i = 1;i<= n;i++) { if (a[i] != b) { sum += a[i]; num += 1; } } double suum = sum*1.0/num; cout << fixed << setprecision(1) << suum; } 题解来喽 注意要万能文件头 我用iost......搞了半天 坑死了(iostream没有取浮点数命令)
-
2
🎉️ 🎉️ 🎉️ 最简代码!!!!!!!!!!!!!!!!!! #include<bits/stdc++.h> using namespace std; int main(){ float pjs; int a[10000], n, sum=0, zx=1000000; cin >> n; for (int i = 0;i < n;i++){ cin >> a[i]; sum+=a[i]; if (a[i] < zx){ zx = a[i]; } } for (int i = 0;i < n;i++){ if (a[i] == zx){ sum-=a[i]; } } pjs=sum / n; printf("%0.1f", pjs); return 0; }
-
1
```cpp
#include<iostream> #include <algorithm> using namespace std; int main() { int n; double a[1000],num = 0.0 ,minn = 0.0,gan = 0,aa = 0; cin >> n; for(int i = 1;i <= n;i++) { cin >> a[i]; } sort(a+1,a+n+1); minn = a[1]; for(int i = 1;i <= n;i++) { if(a[i] == minn) { continue; } num+= a[i]; gan++; } aa = num / gan; printf("%.1f", aa); }
```
</span> -
1
这个题很简单 `
#include <bits/stdc++.h> using namespace std; int main() { int n,min=100000000000000,b=0;//b是min的个数 cin>>n; double sum=0,p;//p是平均值 int a[n];//a[n]是n个苹果各自的重量 for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<n;i++) { sum+=a[i]; if(a[i]<min) { min=a[i]; } } for(int i=0;i<n;i++) { if(a[i]==min) { b++; } } if(b==0) { b++; }//b还是0的话就加1 sum-=min*b; p=sum/(n-b)*1.00; cout<<fixed<<setprecision(1)<<p;//精确输出小数 return 0; }
看完点赞👍
-
1
#include <bits/stdc++.h> using namespace std; int main(){ int n,a[99],minn = 99999999,minnnum = 0,sum = 0; cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i]; minn = min(minn,a[i]); } for(int i = 1;i <= n;i++){ if(a[i] != minn){ minnnum++; sum += a[i]; } }
cout << fixed << setprecision(1) << sum*1.0 / minnnum; return 0;//1:求最小值2:求和3:统计4:平均```
}//学会最重要,不用点赞,不准抄袭
-
1
1.先找出最小值
if(a[i]<=minn)//minn代表最小值 { minn=a[i]; //如果a[i]<=minn,说明a[i]可以当最小值,此时更新minn //循环结束后就可以找到最小的那个a[i]并保存在minn方便我们使用 }
2.去掉最小值,进行求和,并统计相应的个数
for(int i=0;i<n;i++)//遍历所有苹果 { if(a[i]>minn)//找出大于最小值的 { sum+=a[i];//求和的时候不包括那些最小值 ans++;//统计大于最小值的苹果个数 } }
3.求平均值,记得保留一位小数
cout<<fixed<<setprecision(1)<<sum/ans; //注意如果之前定义的int类型,就需要给算出来的结果*1.0,如果是double就不需要
-
0
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, a[1000], min = 99999; double sum = 0; cin >> n; for (int i=1;i<=n;i++) { cin >> a[i]; if (min > a[i]) min = a[i]; } for (int i=1;i<=n;i++) { if (a[i] != min) { sum += a[i]; s += 1; } } printf("%.1lf", sum / s); return 0; }
-
0
#include <bits/stdc++.h> using namespace std; int main() { int n,a[100],x,y = 0; double sum = 0; cin >> n; for (int i = 0;i < n; i ++) { cin >> a[i]; } x = (*min_element(a,a+n));//cpp自带取最小值的函数,(a,a+n)是范围 for (int i = 0; i < n; i ++) { if (a[i] != x) { sum += a[i]; y ++; } } cout << fixed << setprecision(1) << sum / y; return 0; }
信息
- ID
- 218
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 6
- 标签
- 递交数
- 5454
- 已通过
- 1682
- 上传者