首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月15日 02:55
平均值 题解:怎么直接这样就行
P1132
回复 1
|
赞 2
|
浏览 193
#include<bits/stdc++.h> using namespace std; int main(){ double a,b; cin>>a>>b; cout<<(a/2+b/2)<<endl; return 0; }
wwj0102
2025年3月15日 20:39
平均值 题解:%g解决
P1132
回复 0
|
赞 4
|
浏览 138
#include<bits/stdc++.h> using namespace std; int main(){ double a,b; cin >> a >> b; printf("%g\n", (a + b) / 2); return 0; }
zxjrheaven
2025年3月12日 22:54
平均值 题解:暴力,这题这么水正确率为什么比好多难题还低?
P1132
回复 0
|
赞 2
|
浏览 184
#include <bits/stdc++.h> using namespace std; int main() { long long a,b; cin>>a>>b; if((a+b)%2==0)cout<<(a+b)/2; else cout<<(a+b-1)/2<<".5"; retu...
Dayna
2024年12月25日 18:58
平均值 题解:
P1132
回复 0
|
赞 33
|
浏览 821
#include <stdio.h> int main(){ int a,b; scanf("%d%d",&a,&b); if((a+b)%2==0){ printf("%.0lf\n",(double)(a+b)/2); } else printf("%.1lf\n",(double)(a...
2107020202
2024年8月16日 23:40
平均值 题解:
P1132
回复 0
|
赞 7
|
浏览 631
#include<iostream> using namespace std; int n,m; double ave; int main() { cin>>n>>m; ave=(double)(n+m)/2;//将n,m转换为double类型进行计算并赋值给ave cout<<res<<endl;//直接用cout输出 return 0; }
Candour
2024年5月13日 23:40
平均值(C++ cout直接输出就行,不用特判,最短代码) 题解:
P1132
回复 0
|
赞 7
|
浏览 806
C++中std::cout输出浮点数默认精度是6位有效数字 #include<bits/stdc++.h> using namespace std; int a, b; int main() { double res; scanf("%d%d",&a, &b); res = (a + b) * 1.0 / 2; cout << res; return 0; }
Cookie‘s AE86
2024年3月18日 09:49
平均值 题解:注意结果有小数和无小数的输出格式
P1132
回复 0
|
赞 8
|
浏览 964
#include<stdio.h> int main(){ int a, b; scanf("%d %d", &a, &b); int tmp = (a+b)/2; double res; if((a+b)%2 == 1){ res = tmp + 0.5; printf("%.1f", res); }else printf("%d", tmp); return 0; }
零壹
2023年3月22日 12:29
c-主要学会%g的使用
P1132
回复 0
|
赞 16
|
浏览 3.9k
%g用来输出实数,它根据数值的大小,自动选f格式或e格式(选择输出时占宽度较小的一种),且不输出无意义的0。即%g是根据结果自动选择科学记数法还是一般的小数记数法 printf("%g\n", 0.00001234); printf("%g\n", 0.0001234); printf("%.2g\n", 123.45); printf("%.2g\n", 23.45); 上面四句输出...
未央
2021年4月28日 18:35
1132题解
P1132
回复 1
|
赞 3
|
浏览 8.3k
#include <stdio.h> int main() { int A,B; scanf("%d%d",&A,&B); if((A+B)%2==0) printf("%d\n",(A+B)/2); else &...
陈浩程
2019年12月9日 11:10
求两个整数的平均值
P1132
回复 1
|
赞 6
|
浏览 13.1k
#include <stdio.h> int main() { int A,B; scanf ("%d %d",&A,&B); if ((A+B)%2==0) printf ("%d\n",(A+B)/2); else printf ("%.1f\n",(A+B...
1
2
题目
平均值
题解数量
11
发布题解
在线答疑
热门题解
1
平均值 题解:
2
c-主要学会%g的使用
3
平均值 题解:注意结果有小数和无小数的输出格式
4
平均值
5
平均值 题解:
6
平均值(C++ cout直接输出就行,不用特判,最短代码) 题解:
7
求两个整数的平均值
8
平均值 题解:%g解决
9
1132题解
10
平均值 题解:暴力,这题这么水正确率为什么比好多难题还低?