当前位置:网站首页>Finishing (III) - Exercise 2
Finishing (III) - Exercise 2
2022-07-04 06:55:00 【Dan·】
1、 Enter some positive integers (≤26), Program to output the letter triangle attached to the wall with these positive integers as the side length .
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,i,j;
while(cin>>n)
{
char a;
for(i=1;i<=n;i++)
{
cout<<"a";
for(j=1;j<=n-i;j++)
{cout<<" ";}
char a=97;
for(j=1;j<=i;j++)
{cout<<char(a+j-1);}
cout<<endl;
}
cout<<endl;
}
return 0;
}
Input :
3
7
Output :
a a
a ab
aabca a
a ab
a abc
a abcd
a abcde
a abcdef
aabcdefg
2、 Xiao Jin plays cards , When the number of cards in the other party's hand is greater than or equal to 10 Zhang Shi , He will observe each other's expression , If the other party looks nervous , He's out “ Fried ”, If the other party is laughing , He doesn't play any cards .
character 'J' Express that the other party is nervous about applying ,'H' Express that the other party is laughing . Xiao Jinchu “ Fried ”, The output “Z”, If you don't play any cards , The output “pass”.
When the number of cards in the other hand is less than 10 Zhang's time , He will “ Pick up ” The other side's card , That is, the other party goes out “ single ”, He also came out “ single ”, The other party “ double ”, He also made a double .
character 'D’ On behalf of the other party “ single ”,'S' On behalf of the other party “ double ”. Xiao Jinchu “ single ”, The output “D”, If it comes out “ double ”, The output “S”.
#include<iostream>
using namespace std;
int main()
{
int n;char b,c;
cin>>n>>b>>c;
if(n>=10)
{
if(b=='J') cout<<"Z";
if(b=='H') cout<<"pass";
}
if(n<10)
{
if(c=='D') cout<<"D";
if(c=='S') cout<<"S";
}
}
Input 1:
15 H D
Input 2:
9 J S
Output 1:
pass
Output 2:
S
3、 A hundred dollars for a hundred chickens : A chicken is worth five , A hen is worth three , A chicken is worth three , A hundred dollars for a hundred chickens , Ask jiweng 、 mother 、 How much is it ?
#include<iostream>
using namespace std;
int main()
{
for (int a = 0; a <= 20; a++)
for (int b = 0; b <= 33; b++)
for (int c = 0; c <= 100 - a - b; c = c + 3)
if ((a + b + c == 100) and (5 * a + 3 * b + c / 3 == 100))
cout << a << " "<<b<<" " << c;
}
边栏推荐
- About how idea sets up shortcut key sets
- Chapter 1 programming problems
- What is a spotlight effect?
- [problem record] 03 connect to MySQL database prompt: 1040 too many connections
- uniapp 自定义环境变量
- tars源码分析之10
- tars源码分析之9
- Flink memory model, network buffer, memory tuning, troubleshooting
- Latex中的单引号,双引号如何输入?
- Novel website program source code that can be automatically collected
猜你喜欢
云Redis 有什么用? 云redis怎么用?
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
notepad++如何统计单词数量
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
Wechat applet scroll view component scrollable view area
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
Mysql 45讲学习笔记(七)行锁
颈椎、脚气
com. alibaba. nacos. api. exception. NacosException
About how idea sets up shortcut key sets
随机推荐
MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
MySQL 45 lecture learning notes (VI) global lock
[GF (q) + LDPC] regular LDPC coding and decoding design and MATLAB simulation based on the GF (q) field of binary graph
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Design of test cases
uniapp 自定義環境變量
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
【问题记录】03 连接MySQL数据库提示:1040 Too many connections
8. Factory method
2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
If there are two sources in the same job, it will be reported that one of the databases cannot be found. Is there a boss to answer
Google Chrome Portable Google Chrome browser portable version official website download method
uniapp小程序分包
Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
js 常用时间处理函数
《国民经济行业分类GB/T 4754—2017》官网下载地址
【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
2022年6月小结
Cochez une colonne d'affichage dans une colonne de tableau connue
Lottery system test report