当前位置:网站首页>C language: making barrels
C language: making barrels
2022-07-02 09:44:00 【FF small confused acridine~】
A barrel is made of 10 Surrounded by pieces of wood , The capacity of the enclosed barrel , from 10 It is expressed by the length of the shortest piece of wood ( The length value is accurate to one decimal place ). Now there is 100 Pieces of wood , It can be made into 10 A barrel . Please write the program , about 100 Valid inputs ( representative 100 The length of pieces of wood , Can have the same value ), Output the maximum value of the total capacity of the barrel made of wood chips represented by these values ( The result is one decimal place ).
Such as 100 The first value is :25.6 27.8 1.2 28.9 30.1 96.7 32.3 12.3 33.4 11.2 35.6 22.3 37.8 26.7 38.9 29.0 0.1 40.1 36.7 41.2 2.3 42.3 34.5 15.6 43.4 17.8 44.5 23.4 45.6 8.9 47.8 13.4 48.9 20.1 49.0 39.0 51.2 85.6 6.7 53.4 99.0 24.5 55.6 77.8 18.9 56.7 10.1 58.9 16.7 59.0 61.2 82.3 89.0 62.3 3.4 63.4 31.2 64.5 60.1 66.7 9.0 68.9 50.1 46.7 69.0 70.1 21.2 72.3 71.2 73.4 52.3 75.6 5.6 76.7 91.2 78.9 19.0 80.1 65.6 81.2 83.4 67.8 84.5 4.5 86.7 97.8 87.8 79.0 98.9 88.9 90.1 7.8 92.3 74.5 93.4 57.8 94.5 14.5 95.6 54.5
The output is 451.0
Programming requirements :
1、 Please use array to realize ;
2、 When submitting the code of the task, it is necessary to ensure that it conforms to the industry code specification , You need to indent and wrap as necessary .
#include <stdio.h>
int main(void)
{
float temp, arr[100];
float total = 0.0;
int i, j;
for (i = 0; i < 100; i++)
scanf("%f",&arr[i]);
for (i = 0; i < 99; i++) {
for (j = 0; j < 99 - i; j++) {
if (arr[j] > arr[j+1]) {
temp = arr[j+1];
arr[j+1] = arr[j];
arr[j] = temp;
}
}
}
for (i = 0; i < 100; i = i+10)
total += arr[i];
printf("Total capacity is: %.1f",total);
return 0;
}
#include <stdio.h>
int main(void)
{
float arr[100],n=0.0,b;
int a,i,j,m=0;
for(a=0;a<100;++a){
scanf("%f",&arr[a]);
}
for(i=0;i<100-1;++i){
for(j=0;j<100-1-i;++j){
if(arr[j]>arr[j+1]){
b=arr[j];
arr[j]=arr[j+1];
arr[j+1]=b;
}
}
}
while(m<100){
n+=arr[m];
m+=10;
}
printf("%.1f\n",n);
return 0;
}
边栏推荐
- Insight into cloud native | microservices and microservice architecture
- Read 30 minutes before going to bed every day_ day3_ Files
- Activity的创建和跳转
- What is the function of laravel facade
- Image recognition - data augmentation
- Web security and defense
- BugkuCTF-web16(备份是个好习惯)
- Because of hard work, the fruit goes with fate
- Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
- Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
猜你喜欢

Creation and jump of activity

记录一下初次使用Xray的有趣过程

2837xd code generation - stateflow (1)

Insight into cloud native | microservices and microservice architecture

Customize redis connection pool

Learn combinelatest through a practical example

BugkuCTF-web21(详细解题思路及步骤)

逆变器simulink模型——处理器在环测试(PIL)

Error reporting on the first day of work (incomplete awvs unloading)

Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
随机推荐
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
Share a blog (water blog)
Image recognition - data annotation
How to use pyqt5 to make a sensitive word detection tool
ZK configuration center -- configuration and use of config Toolkit
2837xd Code Generation - stateflow (4)
Supplier selection and prequalification of Oracle project management system
How to choose between efficiency and correctness of these three implementation methods of distributed locks?
逆变器simulink模型——处理器在环测试(PIL)
FragmentTabHost实现房贷计算器界面
2837xd Code Generation - Supplement (1)
Personal experience & blog status
C语言之二进制与十进制
2837xd代码生成模块学习(3)——IIC、eCAN、SCI、Watchdog、eCAP模块
Pool de connexion redis personnalisé
记录下对游戏主机配置的个人理解与心得
Bold prediction: it will become the core player of 5g
What are the waiting methods of selenium
图像识别-数据采集