1 条题解
-
0
C :
#include<stdio.h> int main(){ int i,j,n; scanf("%d",&n); for(i=1;i<=n;i++){ for(j=1;j<=n-i;j++){ printf("*"); } for(j=1;j<=2*i-1;j++){ printf("@"); } for(j=1;j<=n-i;j++){ printf("*"); } printf("\n"); } return 0; }
C++ :
#include <iostream> using namespace std; int main(){ int i,j,n; cin>>n; for(i = 1;i <= n;i++){ for(j = 1;j <= n - i;j++) cout<<"*"; for(j = 1;j <= 2 * i - 1;j++) cout<<"@"; for(j = 1;j <= n - i;j++) cout<<"*"; cout<<endl; } }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int a = sc.nextInt(); sc.close(); for(int i=1;i<=a;i++) { for(int j=1;j<=a-i;j++) { System.out.print("*"); } for(int k=1;k<=i*2-1;k++) { System.out.print("@"); } for(int j=1;j<=a-i;j++) { System.out.print("*"); } System.out.println(); } } }
Python :
n = int(input()) for i in range(1, n + 1): for j in range(1, n - i + 1): print("*", end='') for j in range(1, 2 * i): print('@', end='') for j in range(1, n - i + 1): print("*", end='') print()
- 1
信息
- ID
- 2414
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者