当前位置:网站首页>每日刷题巩固知识
每日刷题巩固知识
2022-07-28 02:06:00 【旧梦拾遗186】
作者:旧梦拾遗186
目录
公务员面试
1.题目:
描述
公务员面试现场打分。有7位考官,从键盘输入若干组成绩,每组7个分数(百分制),去掉一个最高分和一个最低分,输出每组的平均成绩。
(注:本题有多组输入)
输入描述:
每一行,输入7个整数(0~100),代表7个成绩,用空格分隔。
输出描述:
每一行,输出去掉最高分和最低分的平均成绩,小数点后保留2位,每行输出后换行。
示例1
输入:
99 45 78 67 72 88 60复制输出:
73.00
2.答案:
#include<stdio.h> int main() { int max = 0; int min = 100; int n = 0; int count = 0; int sum = 0; while (scanf("%d", &n) == 1) { count++; if (n > max) { max = n; } if (n < min) { min = n; } sum = sum + n; if (count == 7) { float su = (sum - max - min) / 5.0; printf("%.2lf\n", su); count = 0; max = 0; min = 100; sum=0; } } return 0; }
箭形图案
1.题目:
描述
KiKi学习了循环,BoBo老师给他出了一系列打印图案的练习,该任务是打印用“*”组成的箭形图案。
输入描述:
本题多组输入,每行一个整数(2~20)。
输出描述:
针对每行输入,输出用“*”组成的箭形。
示例1
输入:
2复制输出:
* ** *** ** *复制
示例2
输入:
3复制输出:
* ** *** **** *** ** *复制
示例3
输入:
4复制输出:
* ** *** **** ***** **** *** ** *
答案:
#include<stdio.h> int main() { int n = 0; int i = 0; int j = 0; while ((scanf("%d", &n)) == 1) { for (i = 0; i < n+1; i++) { for (j = 0; j < 2 * (n - i) ; j++) { printf(" "); } for (j = 0;j<=i; j++) { printf("*"); } printf("\n"); } for (i = 0; i < n; i++) { for (j = 0; j < 2 *(i+1) ; j++) { printf(" "); } for (j = n; j >=i+1; j--) { printf("*"); } printf("\n"); } } return 0; }
结构体类型大小计算
下面代码的结果是( ) int main() { unsigned char puc[4]; struct tagPIM { unsigned char ucPim1; unsigned char ucData0 : 1; unsigned char ucData1 : 2; unsigned char ucData2 : 3; }*pstPimData; pstPimData = (struct tagPIM*)puc; memset(puc,0,4); pstPimData->ucPim1 = 2; pstPimData->ucData0 = 3; pstPimData->ucData1 = 4; pstPimData->ucData2 = 5; printf("%02x %02x %02x %02x\n",puc[0], puc[1], puc[2], puc[3]); return 0; }A.02 03 04 05
B.02 29 00 00
C.02 25 00 00
D.02 29 04 00
解析:
puc是一个char数组,每次跳转一个字节,结构体不是,它只有第一个元素单独享用一字节,其他三个元素一起共用一字节,所以puc被结构体填充后,本身只有两个字节会被写入,后两个字节肯定是0,至此AD排除,然后第一个字节是2就是2了,第二个字节比较麻烦,首先ucData0给了3其实是越界了,1位的数字只能是0或1,所以11截断后只有1,同理ucData1给的4也是越界的,100截断后是00,只有5的101是正常的。填充序列是类似小端的低地址在低位,所以排列顺序是00 101 00 1。也就是0010 1001,即0x29,故选B。
边栏推荐
- Data Lake: database data migration tool sqoop
- [ACNOI2022]总差一步
- Constant power wireless charging based on stm32
- [leetcode] 13. linked list cycle · circular linked list
- 微服务架构统一安全认证设计与实践
- selenium+pytest+allure综合练习
- What kind of job is social phobia suitable for? Can you do we media?
- 社恐适合什么工作?能做自媒体吗?
- Docker高级篇-Docker容器内Redis集群配置
- Newline required at end of file but not found.
猜你喜欢
![[TA frost wolf \u may hundred people plan] Figure 3.5 early-z and z-prepass](/img/85/2b6c9cf83340ee8bc01e85f77ec101.png)
[TA frost wolf \u may hundred people plan] Figure 3.5 early-z and z-prepass
![[leetcode] 13. linked list cycle · circular linked list](/img/58/c8796bb5ed96d09325b8f2fa6a709e.png)
[leetcode] 13. linked list cycle · circular linked list

ROS的调试经验

为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
![[image defogging] image defogging based on dark channel and non-mean filtering with matlab code](/img/39/6266eb14deac9f38b7e95f7291067e.png)
[image defogging] image defogging based on dark channel and non-mean filtering with matlab code

数据中台建设(三):数据中台架构介绍

别再用 offset 和 limit 分页了,性能太差!

IO flow: node flow and processing flow are summarized in detail.

vscode debug显示多列数据

MySQL is shown in the figure. The existing tables a and B need to be associated with a and B tables through projectcode to find idcardnum with different addresses.
随机推荐
CSDN TOP1“一个处女座的程序猿“如何通过写作成为百万粉丝博主?
IO flow: node flow and processing flow are summarized in detail.
[wechat applet development (V)] the interface is intelligently configured according to the official version of the experience version of the development version
1313_ Pyserial installation and document generation
Retainface use error: modulenotfounderror: no module named'rcnn.cyton.bbox'
Data Lake: flume, a massive log collection engine
【微信小程序开发(五)】接口按照根据开发版体验版正式版智能配置
写英文IEEE论文的技巧
数据中台夯实数据基础
Superparameter adjustment and experiment - training depth neural network | pytorch series (26)
RTSP/Onvif协议EasyNVR视频平台一键升级方案的开发设计逻辑
What "posture" does JD cloud have to promote industrial digitalization to climb to a "new level"?
[software testing] - unittest framework for automated testing
Flutter神操作学习之(满级攻略)
42.js -- precompiled
分布式事务——Senta(一)
Gbase8s how to delete data in a table with a foreign key relationship
Ah Han's story
Trivy [1] tool scanning application
Opengauss source code, what ide tools are used to manage, edit and debug?

