• CDOJ 训练题


    从标准输入设备读入正整数n和字符ch, 输出一个由字符ch组成的字符三角形.

    Standard Input

    第一行是T(T<=100),表明后面有T组测试数据,每组测试数据由正整数n(n<=30)和字符ch构成,两者之间有一个空格。

    Standard Output

    对应每一组测试数据,输出符合要求的字符三角形, 两组结果之间有一个空行。

    Samples

    InputOutput
    3
    1 9
    3 *
    6 X
    
    9
    
    *
    **
    ***
    
    X
    XX
    XXX
    XXXX
    XXXXX
    XXXXXX
    
    
     
     
    Problem ID 1885
    Problem Title 字符三角形
    Time Limit 1000 ms
    Memory Limit 64 MiB
    Output Limit 64 MiB
    Source wxiaoping - 2018.4.16
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int t,n;
    10     char ch;
    11     scanf("%d",&t);
    12     for(int i=1;i<=t;i++){
    13         scanf("%d %c",&n,&ch);
    14         for(int j=1;j<=n;j++){
    15             for(int k=1;k<=j;k++){
    16                 printf("%c",ch);
    17             }
    18             printf("
    ");
    19         }
    20     }
    21     return 0;
    22 }
    字符三角形

    从标准输入设备读入三个整数a、b、c,找出中间数并输出。 中间数定义为: 若三数不相等,则第2大的数是中间数;若有两个数相等,则最大数作为中间数。

    Standard Input

    第一行是T(T<=10),表明后面有T组测试数据,每组测试数据由三个整数构成,相邻两数之间有一个空格。

    Standard Output

    对应每一组测试数据,输出其中间数。

    Samples

    InputOutput
    8
    45 23 85
    12 56 12
    34 23 34
    12 12 12
    234 567 890
    876 458 321
    456 456 777
    2345 789 789
    
    45
    56
    34
    12
    567
    458
    777
    2345
    
     
     
    Problem ID 1886
    Problem Title 中间数
    Time Limit 1000 ms
    Memory Limit 64 MiB
    Output Limit 64 MiB
    Source wxiaoping - 2018.4.16
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int t,a,b,c;
    10     scanf("%d",&t);
    11     for(int i=1;i<=t;i++){
    12         scanf("%d%d%d",&a,&b,&c);
    13         if(a>b)swap(a,b);
    14         if(a>c)swap(a,c);
    15         if(b>c)swap(b,c);
    16         if(a!=b&&b!=c&&a!=c)printf("%d
    ",b);
    17         else printf("%d
    ",c);
    18     }
    19     return 0;
    20 }
    中间数

    从标准输入设备整数n和字符ch, 输出一个由字符ch组成的字符三角形.

    Standard Input

    第一行是T(T<=10),表明后面有T组测试数据,每组测试数据由正整数n(n<=30)和字符ch构成,两者之间有一个空格。

    Standard Output

    对应每一组测试数据,输出符合要求的字符三角形, 两组结果之间有一个空行。

    Samples

    InputOutput
    3
    1 9
    3 *
    6 X
    
    9
    
      *
     **
    ***
    
         X
        XX
       XXX
      XXXX
     XXXXX
    XXXXXX
    
    
     
     
    Problem ID 1887
    Problem Title 字符三角形2
    Time Limit 1000 ms
    Memory Limit 64 MiB
    Output Limit 64 MiB
    Source wxiaoping - 2018.4.16
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int t,n;
    10     char ch;
    11     scanf("%d",&t);
    12     for(int i=1;i<=t;i++){
    13         scanf("%d %c",&n,&ch);
    14         for(int j=1;j<=n;j++){
    15             for(int k=1;k<=n-j;k++){
    16                 printf(" ");
    17             }
    18             for(int k=1;k<=j;k++){
    19                 printf("%c",ch);
    20             }
    21             printf("
    ");
    22         }
    23         printf("
    ");
    24     }
    25     return 0;
    26 }
    字符三角形2

    运动员跳水时,有n个评委打分,分数为10分制,且有两位小数。得分规则为:去掉最高分和最低分,求剩下分数的平均值,就是运动员的最终得分。

    Standard Input

    有多组测试数据。第一行是整数T (T <= 100),表示测试数据的组数,随后有T组测试数据。每一组测试数据占一行,分别为整数n和n个评委的打分,相邻数之间有一个空格。其中,2<n≤100。

    Standard Output

    对应每组输入,输出该运动员的得分,保留2位小数。

    Samples

    InputOutput
    3
    9 6.21 9.19 6.34 9.22 6.85 8.50 6.85 6.95 6.03
    8 6.75 6.23 9.86 9.37 6.90 7.88 9.13 6.15
    9 9.11 7.68 8.93 7.53 8.92 9.52 7.78 8.70 6.69
    
    7.27
    7.71
    8.38
    
     
     
    Problem ID 1888
    Problem Title 跳水打分问题
    Time Limit 1000 ms
    Memory Limit 64 MiB
    Output Limit 64 MiB
    Source wxiaoping - 2018.4.16
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int t,n;
    10     scanf("%d",&t);
    11     for(int i=1;i<=t;i++){
    12         double a,sum=0,mx=0,mn=10,ans;
    13         scanf("%d",&n);
    14         for(int j=1;j<=n;j++){
    15             scanf("%lf",&a);
    16             sum+=a;
    17             mx=max(mx,a);
    18             mn=min(mn,a);
    19         }
    20         sum-=(mx+mn);
    21         ans=sum/(n-2);
    22         printf("%.2lf
    ",ans);
    23     }
    24     return 0;
    25 }
    跳水打分问题

    有一天silentsky和lcy同学去教室上自习。silentsky百无聊赖地看着书本,觉得很无聊,看着右手边的lcy认真仔细的在画着她繁重的物理实验报告的图。silentsky无聊地弄着他的脉动瓶子,结果一不小心就把瓶盖弄到了lcy刚画好的坐标纸上,而且冥冥之中仿佛有一双手在安排,瓶盖的中心正好和坐标纸的中心重合了,瓶盖的边缘有水,会弄湿坐标纸的。 lcy很生气,后果很严重。

    于是,lcy由此情形想出了一道难题问silentsky,如果他回答正确了。lcy就原谅了silentsky并且答应他星期天去看暮光之城2的请求,不然一切都免谈。然后silentsky就回去面壁思过了,现在silentsky好无助的,希望得到广大编程爱好者的好心帮助。

    问题是这样的: lcy现在手上有一张2n imes 2n2n×2n的坐标纸,而silentsky的圆形瓶盖的直径正好有2 imes n-12×n1大,现在lcy想知道 silentsky到底弄湿了多少个坐标纸的格子(坐标纸是由1 imes 11×1的小格子组成的表格)

    如果还是有人觉得理解不了焦急的silentsky的意思。干脆silentsky做下翻译,毕竟silentsky还是多了解lcy的O(∩_∩)O~。

    问题就是给你一个2n imes 2n2n×2n的正方形格子,分成1 imes 11×1的格子,然后以中心为原点画一个直径为2n - 12n1的圆,问圆的周线穿过了多少个格子。

    .*

    Standard Input

    含有多组测试数据,每组数据都包含一个正整数nnnleq 1000n1000)。

    n = 0n=0的时候结束程序,证明silentky经受住考验了的O(∩_∩)O~

    Standard Output

    对于每个nn,输出被瓶盖边缘的水弄湿了的格子数为多少。

    Samples

    InputOutput
    1
    2
    0
    4
    12
     
     
    Problem ID 156
    Problem Title 约会
    Time Limit 1000 ms
    Memory Limit 64 MiB
    Output Limit 64 MiB
    Source love8909 & silentsky
     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<iostream>
     6 using namespace std;
     7 
     8 int main(){
     9     int n;
    10     scanf("%d",&n);
    11     while(n!=0){
    12         printf("%d
    ",n*8-4);
    13         scanf("%d",&n);
    14     }
    15     return 0;
    16 }
    约会
  • 相关阅读:
    GridControl主从表设置
    Asp.net Ajax框架教程
    实现类似百度下拉框自动匹配功能
    将一个DataTable分解成多个DataTable
    找不到可安装的ISAM ,asp.net读取数据丢失,解决的一列里有字符与数字的
    StringCollection FAQ [C#, BCL]
    从枚举的初始化说起 [C#]
    当多态遇上数组 ... [C++] (Rewritten)
    我并不是不闻不问![C#]
    当多态遇上数组 ... [C++, C++/CLI, C#]
  • 原文地址:https://www.cnblogs.com/chezhongyang/p/11685963.html
Copyright © 2020-2023  润新知