洛谷题解
入门1(顺序结构)
p1000 超级玛丽游戏
__关于printf的输出格式__
P5704【深基2.例6】字母转换
P5705 【深基2.例7】数字反转
__万能头文件__
__reverse函数__
P5706 【深基2.例8】再分肥宅水
__取整函数__
P1425 小鱼的游泳时间
题解思路
P5708 【深基2.习2】三角形面积
__关于float与double类型__
P5709 【深基2.习6】Apples Prologue
第一次见识什么叫题目有坑,考虑要更细致周全
P2181 对角线
__数学题__
__超出long long范围,巧用Python__
入门1(顺序结构)
p1000 超级玛丽游戏
//题解(多行字符串写法)
#includeint main() {
printf(
" ********\n"
" ************\n"
" ####....#.\n"
" #..###.....##....\n"
" ###.......###### ### ###\n"
" ........... #...# #...#\n"
" ##*####### #.#.# #.#.#\n"
" ####*******###### #.#.# #.#.#\n"
" ...#***.****.*###.... #...# #...#\n"
" ....**********##..... ### ###\n"
" ....**** *****....\n"
" #### ####\n"
" ###### ######\n"
"##############################################################\n"
"#...#......#.##...#......#.##...#......#.##------------------#\n"
"###########################################------------------#\n"
"#..#....#....##..#....#....##..#....#....#####################\n"
"########################################## #----------#\n"
"#.....#......##.....#......##.....#......# #----------#\n"
"########################################## #----------#\n"
"#.#..#....#..##.#..#....#..##.#..#....#..# #----------#\n"
"########################################## ############\n"
);
return 0;
}
关于printf的输出格式
# include int main(void)
{
printf("Hello World!\n"); // \n表示换行
return 0;
}
printf("%.3f\n%d",c,b);//控制小数位数
P5704【深基2.例6】字母转换
//题解
#includeusing namespace std;
int main()
{
char a;
cin>>a;
cout<
P5705 【深基2.例7】数字反转
万能头文件
#include
reverse函数
reverse(a.begin(),a.end());
P5706 【深基2.例8】再分肥宅水
(误读题目,但也有收获)
取整函数
floor(x) //小于或等于x的最大整数
ceil(x) //大于或等于x的最大整数
P1425 小鱼的游泳时间
题解思路
#includeusing namespace std;
int main()
{
int a,b,c,d,x,y;
cin>>a>>b>>c>>d;
x=c-a;
y=d-b;
if(y<0) //硬算小时数和分钟数,解决特殊情况
{
x--;
y+=60;
}
cout<
P5708 【深基2.习2】三角形面积
关于float与double类型
能用double就不用float
P5709 【深基2.习6】Apples Prologue
第一次见识什么叫题目有坑,考虑要更细致周全
#includeusing namespace std;
int main()
{
int m,t,s,x,y;
cin>>m>>t>>s;
if(t>0) x=ceil((s*1.0)/t);
else
{
cout<<0;
return 0; //这里注意
}
y=m-x;
if(y<=0) cout<<0;
else cout<
P2181 对角线
数学题
真的不会写出公式
超出long long范围,巧用Python
x = int(input())
print ( x * ( x - 1 )// 2 * ( x - 2 ) // 3 * ( x - 3 ) // 4 )