zoukankan      html  css  js  c++  java
  • TOJ1056: 英文金曲大赛

    Time Limit Exceeded:

     1 #include<iostream>
     2 #include<string>
     3 #include<iomanip>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8     string s;
     9     double a[7];
    10     while (1)
    11     {
    12         double sum = 0;
    13         for (int i = 0;i < 7;++i)
    14         {
    15             cin >> a[i];
    16             sum += a[i];
    17         }
    18         cin >> s;
    19         for (int j = 0;j < 7;++j)
    20         {
    21             for (int k = j;k < 7;k++)
    22             {
    23                 if (a[j] > a[k])
    24                 {
    25                     double temp;
    26                     temp = a[j];a[j] = a[k];a[k] = temp;
    27                 }
    28             }
    29         }
    30         cout << s<<" ";
    31         sum=sum - a[0] - a[6];
    32         cout << setiosflags(ios::fixed)<<setprecision(2)<<sum/5 << endl;
    33     }
    34     return 0;
    35 }
    选择排序
     1 #include<iostream>
     2 #include<string>
     3 #include<iomanip>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8     string s;
     9     double a[7];
    10     while (1)
    11     {
    12         double sum = 0;
    13         for (int i = 0;i < 7;++i)
    14         {
    15             cin >> a[i];
    16             sum += a[i];
    17         }
    18         cin >> s;
    19         for (int j = 1;j < 7;++j)
    20         {
    21             if (a[j] >= a[j - 1])
    22             {
    23                 double temp;
    24                 temp = a[j];a[j] = a[j - 1];a[j - 1] = temp;
    25             }
    26         }
    27         cout << s<<" ";
    28         sum=sum - a[0] - a[6];
    29         cout << setiosflags(ios::fixed)<<setprecision(2)<<sum/5 << endl;
    30     }
    31     return 0;
    32 }
    冒泡排序

    Accepted:

     1 #include<iostream>
     2 #include<string>
     3 #include<iomanip>
     4 using namespace std;
     5 
     6 void sort(double a[])
     7 {
     8     for (int j = 0;j < 7;++j)
     9     {
    10         for (int k = j;k < 7;k++)
    11         {
    12             if (a[j] > a[k])
    13             {
    14                 double temp;
    15                 temp = a[j];a[j] = a[k];a[k] = temp;
    16             }
    17         }
    18     }
    19 }
    20 
    21 int main()
    22 {
    23     string s;
    24     double a[7];
    25     while ((scanf("%lf",&a[0]))!=EOF)
    26     {
    27         double sum = 0;
    28         for (int i = 1;i < 7;++i)
    29         {
    30             cin >> a[i];
    31         }
    32         cin >> s;
    33         sort(a);
    34         cout << s<<" ";
    35         for (int ii = 1;ii < 6;++ii)
    36             sum += a[ii];
    37         cout << setiosflags(ios::fixed)<<setprecision(2)<<sum/5 << endl;
    38     }
    39     return 0;
    40 }
    View Code
  • 相关阅读:
    CentOS7 部署K8S集群成功后,重启就不能用了???k8s环境自启动
    k8s环境部署本地.net core web项目
    CentOS7 部署K8S集群,最新版1.17.3-0
    VM安装Linux Centos7.0虚拟机
    Dapper.Contrib拓展及数据库生成实体
    解决EF没有生成字段和表说明
    C#使用AutoMapper6.2.2.0进行对象映射
    .NET Core2.0+MVC 用Redis/Memory+cookie实现的sso单点登录
    Asp.net Core2.0 缓存 MemoryCache 和 Redis
    目录
  • 原文地址:https://www.cnblogs.com/hansichen/p/7222225.html
Copyright © 2011-2022 走看看