fkjj.net
当前位置:首页 >> C语言.二维数组打印空心菱形.星号数目由用户输入... >>

C语言.二维数组打印空心菱形.星号数目由用户输入...

#include int main() { int i,j,k,line,m; printf("请输入行数:"); scanf("%d",&line); m=(line+1)/2; for(i=1;i

写了一下,能满足你要求: #include main() { int n,i,j; printf("input n:\n"); scanf("%d",&n); for(i=0;i

#include "stdio.h"#include "stdlib.h"int main(void){ int i,j,t,n,k; while(scanf("%d",&n)!=1 || n

2层循环 外层控制行,内层控制每行显示的"*"和" ". 菱形的话外层循环需要两个 实心的上半部分如下 for(int i=1;i

n = input() for i in range(n): if i > n/2: t = n-1-i else: t = i s1 = ' ' * (n/2 - t) s2 = ' ' * (2*t - 1) if t == 0: print s1 + '*' else: print s1 + '*' + s2 + '*'

#include void main() { int i,j,k,n; printf("输入奇数:"); scanf("%d",&n); for (i=1; i=i;j--) printf(" "); printf("*"); for (k=1; k=1; i--) { for (j=n-1; j>=i; j--) printf(" "); printf("*"); for (k=1; k

import java.util.Scanner; public class Diamond { public static void main(String[] args) { int length=1;//存储菱形的边长的变量 Scanner sc =new Scanner(System.in);//输入数据的扫描对象 System.out.println("请输入菱形的边长:"); len...

public class Test { public static void print(int n){ int index1 = n/2; int index2 = index1; for (int i = 0; i < n; i++){ for (int j = 0; j < 2 * n - 1; j++){ if (j == index1 || j == index2){ System.out.print("*"); } else{ Syste...

网站首页 | 网站地图
All rights reserved Powered by www.fkjj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com