CDOJ Training Problems

Reads from the standard input character and integer n ch, outputting a character composed of a character ch triangle.

Standard Input

The first line is T (T <= 100), followed by a T shows that the test data set, each set of test data is composed of (30 n <=) and character ch positive integer n, there is a space therebetween.

Standard Output

Corresponding to each set of test data, the output character triangle meet the requirements, there is a blank line between the two sets of results.

Samples

Input Output
3
1 9
3 *
6 X
9

*
**
***

X
XX
XXX
XXXX
XXXXX
XXXXXX

 
 
Problem ID 1885
Problem Title Character triangle
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("\n");
19         }
20     }
21     return 0;
22 }
Character triangle

Reads from the standard input device three integers a, b, c, and identify the number of intermediate outputs. The middle number is defined as: If three numbers are not equal, the larger the number of the second intermediate number; if the two numbers are equal, as the maximum number of intermediate numbers.

Standard Input

The first line is T (T <= 10), showed a T-back test data set, each set of test data is composed of three integers, there is a space between two adjacent numbers.

Standard Output

Corresponding to each set of test data, wherein the output number of rooms.

Samples

Input Output
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 The middle number
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\n",b);
17         else printf("%d\n",c);
18     }
19     return 0;
20 }
The middle number

N an integer from standard input and character ch, the output of a character by the character triangle ch thereof.

Standard Input

The first line is T (T <= 10), showed a T-back test data set, each set of test data constituted by (30 n <=) and character ch positive integer n, there is a space therebetween.

Standard Output

Corresponding to each set of test data, the output character triangle meet the requirements, there is a blank line between the two sets of results.

Samples

Input Output
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("\n");
22         }
23         printf("\n");
24     }
25     return 0;
26 }
字符三角形2

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

Standard Input

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

Standard Output

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

Samples

Input Output
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\n",ans);
23     }
24     return 0;
25 }
跳水打分问题

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

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

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

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

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

.*

Standard Input

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

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

Standard Output

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

Samples

Input Output
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",n*8-4);
13         scanf("%d",&n);
14     }
15     return 0;
16 }
约会

 

Guess you like

Origin www.cnblogs.com/chezhongyang/p/11685963.html