当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
图像识别-数据标注
Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
2837xd 代码生成——补充(2)
Web security and defense
Personal experience & blog status
2837xd code generation - Supplement (2)
FragmentTabHost实现房贷计算器界面
Activity的创建和跳转
How to use PHP spoole to implement millisecond scheduled tasks
Share a blog (water blog)
随机推荐
zk配置中心---Config Toolkit配置与使用
自定義Redis連接池
2837xd 代码生成——总结篇
Because of hard work, the fruit goes with fate
What is the function of laravel facade
Demand delineation executive summary
VIM操作命令大全
Int to string, int to qstring
Who is better for Beijing software development? How to find someone to develop system software
大学生四六级作文模板(自创版,成功跨过六级)
Enterprise level SaaS CRM implementation
2837xd代码生成模块学习(3)——IIC、eCAN、SCI、Watchdog、eCAP模块
Memories of a chat
Learn combinelatest through a practical example
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
Tools used for Yolo object recognition and data generation
Read Day5 30 minutes before going to bed every day_ All key values in the map, how to obtain all value values
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
Record personal understanding and experience of game console configuration
C语言之数据插入