從標准輸入設備讀入正整數n和字符ch, 輸出一個由字符ch組成的字符三角形.
Standard Input
第一行是T(T<=100),表明后面有T組測試數據,每組測試數據由正整數n(n<=30)和字符ch構成,兩者之間有一個空格。
Standard Output
對應每一組測試數據,輸出符合要求的字符三角形, 兩組結果之間有一個空行。
Samples
Input | Output |
---|---|
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("\n"); 19 } 20 } 21 return 0; 22 }
從標准輸入設備讀入三個整數a、b、c,找出中間數並輸出。 中間數定義為: 若三數不相等,則第2大的數是中間數;若有兩個數相等,則最大數作為中間數。
Standard Input
第一行是T(T<=10),表明后面有T組測試數據,每組測試數據由三個整數構成,相鄰兩數之間有一個空格。
Standard Output
對應每一組測試數據,輸出其中間數。
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 | 中間數 |
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 }
從標准輸入設備整數n和字符ch, 輸出一個由字符ch組成的字符三角形.
Standard Input
第一行是T(T<=10),表明后面有T組測試數據,每組測試數據由正整數n(n<=30)和字符ch構成,兩者之間有一個空格。
Standard Output
對應每一組測試數據,輸出符合要求的字符三角形, 兩組結果之間有一個空行。
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 }
運動員跳水時,有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×n−1大,現在lcy想知道 silentsky到底弄濕了多少個坐標紙的格子(坐標紙是由1\times 11×1的小格子組成的表格)
如果還是有人覺得理解不了焦急的silentsky的意思。干脆silentsky做下翻譯,畢竟silentsky還是多了解lcy的O(∩_∩)O~。
問題就是給你一個2n\times 2n2n×2n的正方形格子,分成1\times 11×1的格子,然后以中心為原點畫一個直徑為2n - 12n−1的圓,問圓的周線穿過了多少個格子。
Standard Input
含有多組測試數據,每組數據都包含一個正整數nn(n\leq 1000n≤1000)。
當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 }