openjudge1.1


1.1.1

描述
對於大部分編程語言來說,編寫一個能夠輸出“Hello, World!”的程序往往是最基本、最簡單的。因此,這個程序常常作為一個初學者接觸一門新的編程語言所寫的第一個程序,也經常用來測試開發、編譯環境是否能夠正常工作。

現在你就需要完成這樣一個程序。

#include<iostream>            
using namespace std; 
int main()                  
{
	cout<<"Hello, World!"<<endl;   
	return 0;             
}

1.1.2

描述
輸入三個整數,把第二個輸入的整數輸出。

#include<iostream>            
using namespace std; 
int main()                  
{
	int a,b,c;
	cin>> a>>b>> c;
	cout<<b<<endl;   
	return 0;
}

1.1.3

描述
讀入三個整數,按每個整數占8個字符的寬度,右對齊輸出它們。

#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%8d %8d %8d",a,b,c);
	return 0;
}

1.1.4

描述
讀入一個單精度浮點數,保留3位小數輸出這個浮點數。

#include<iostream>
using namespace std;
int main()
{
	float a;
	scanf("%f",&a);
	printf("%.3f",a);
	return 0;
}

1.1.5

描述
讀入一個雙精度浮點數,保留12位小數,輸出這個浮點數。

#include<iostream>
using namespace std;
int main()
{
	double a;
	scanf("%lf",&a);
	printf("%.12lf",a);
	return 0;
}

1.1.6

描述
讀入一個字符,一個整數,一個單精度浮點數,一個雙精度浮點數,然后按順序輸出它們,並且要求在他們之間用一個空格分隔。輸出浮點數時保留6位小數。

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char a;
	int b;
	float c;
	double d;
	scanf("%c%d%f%lf",&a,&b,&c,&d);
	printf("%c %d %.6f %.6lf",a,b,c,d);
	return 0;
}

1.1.7

描述
讀入一個雙精度浮點數,分別按輸出格式“%f”,“%f”保留5位小數,“%e”和“%g”的形式輸出這個整數,每次在單獨一行上輸出。

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double a;
	scanf("%lf",&a);
	printf("%f\n%.5f\n%e\n%g\n",a,a,a,a);
	return 0;
}

1.1.8

描述
給定一個字符,用它構造一個底邊長5個字符,高3個字符的等腰字符三角形。

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char a;
	cin>>a;
	cout<<"  "<<a<<endl;
	cout<<" "<<a<<a<<a<<endl;
	cout<<a<<a<<a<<a<<a<<endl;
	return 0;
}

1.1.9

描述
給定一個字符,用它構造一個對角線長5個字符,傾斜放置的菱形。

#include<iostream>
using namespace std;
int main()
{
	char a;
	cin>>a;
    cout<<"  "<<a<<endl;
    cout<<" "<<a<<a<<a<<endl;
    cout<<a<<a<<a<<a<<a<<endl;
    cout<<" "<<a<<a<<a<<endl;
    cout<<"  "<<a<<endl;
}

1.1.10

描述
超級瑪麗是一個非常經典的游戲。請你用字符畫的形式輸出超級瑪麗中的一個場景。

#include<iostream>
using namespace std;
int main()
{
    cout<<"                ********"<<endl;
    cout<<"               ************"<<endl;
    cout<<"               ####....#."<<endl;
    cout<<"             #..###.....##...."<<endl;
    cout<<"             ###.......######              ###                 ###           ###           ###"<<endl;
    cout<<"                ...........               #...#               #...#         #...#         #...#"<<endl;
    cout<<"               ##*#######                 #.#.#               #.#.#         #.#.#         #.#.#"<<endl;
    cout<<"            ####*******######             #.#.#               #.#.#         #.#.#         #.#.#"<<endl;
    cout<<"           ...#***.****.*###....          #...#               #...#         #...#         #...#"<<endl;
    cout<<"           ....**********##.....           ###                 ###           ###           ###"<<endl;
    cout<<"           ....****    *****...."<<endl;
    cout<<"             ####        ####"<<endl;
    cout<<"           ######        ######"<<endl;
    cout<<"##############################################################              ##################################"<<endl;
    cout<<"#...#......#.##...#......#.##...#......#.##------------------#              #...#......#.##------------------#"<<endl;
    cout<<"###########################################------------------#              ###############------------------#"<<endl;
    cout<<"#..#....#....##..#....#....##..#....#....#####################              #..#....#....#####################"<<endl;
    cout<<"##########################################    #----------#                  ##############    #----------#"<<endl;
    cout<<"#.....#......##.....#......##.....#......#    #----------#                  #.....#......#    #----------#"<<endl;
    cout<<"##########################################    #----------#                  ##############    #----------#"<<endl;
    cout<<"#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#                  #.#..#....#..#    #----------#"<<endl;
    cout<<"##########################################    ############                  ##############    ############"<<endl;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM