当前位置:网站首页>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;
}
边栏推荐
- tars源码分析之7
- leetcode 310. Minimum Height Trees
- regular expression
- 响应式——媒体查询
- Summary of leetcode BFS question brushing
- Selection (021) - what is the output of the following code?
- Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
- tars源码分析之1
- tars源码分析之5
- Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc
猜你喜欢
uniapp 自定义环境变量
The most effective futures trend strategy: futures reverse merchandising
响应式——媒体查询
leetcode825. Age appropriate friends
MySQL 45 lecture learning notes (VII) line lock
A new understanding of how to encrypt industrial computers: host reinforcement application
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Another company raised the price of SAIC Roewe new energy products from March 1
【GF(q)+LDPC】基于二值图GF(q)域的规则LDPC编译码设计与matlab仿真
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
随机推荐
Set JTAG fuc invalid to normal IO port
js 常用时间处理函数
2022年,或许是未来10年经济最好的一年,2022年你毕业了吗?毕业后是怎么计划的?
Centos8 install mysql 7 unable to start up
About how idea sets up shortcut key sets
Uniapp applet subcontracting
List of top ten professional skills required for data science work
Realize IIC data / instruction interaction with micro batg135
The final week, I split
What is Gibson's law?
The important role of host reinforcement concept in medical industry
centos8安装mysql.7 无法开机启动
在已经知道表格列勾选一个显示一列
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Mysql 45讲学习笔记(十三)表数据删掉一半,表文件大小不变
Selection (021) - what is the output of the following code?
Analysis of tars source code 1
uniapp 自定义环境变量
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA