java编程题求解:使用for语句打印显示下列数字: 1 121 12321 1234321
public static void main(String[] args) { for (int i = 1; i < 5; i++) { for (int j = 1; j < i; j++) { System.out.print(j);} for (int j = i; j >= 1; j--) { System.out.print(j);} System.out.print(" ");} } ...
1 121 12321 1234321 C语言程序用for循环,怎么编
for(i=1;i<5;i++){ for(j=1;j<=i;j++)printf("%d",j); \/*打印前半部分*\/ for(j=i-1;j>0;j--)printf("%d",j);\/*打印后半部分*\/ printf(" "); \/*打印空格部分*\/ }
...层数在程序运行时由键盘输入 1 121 12321 1234321
int main(){ int i,j,k=1,temp;printf("please input your layer:");scanf("%d",&temp);if(temp>10){ printf("input wrong");} printf("\\n");for(i=1;i<=temp;i++){ k=1;for(j=1;j<=temp-i;j++)printf(" ");for(;j<=temp;j++)printf("%d",k++);for(k=k-2;k...
用VB编出程序 1 121 12321 1234321 利用FOR语句和IF语句和数列编
Private Sub Command1_Click()Dim i, a As Integer, b As String Do a = Val(InputBox("输入层数:"))Loop While a < 2 Or a > 9 For i = 1 To a b = ""For j = 1 To (i - 1) * 2 + 1 b = b & IIf(j > i, CStr(i * 2 - j), CStr(j))Next Print Space...
...用c语言写。 1 121 12321 1234321 12321 121 1
void output(int n){ int i,j,temp;for(i=1;i<=n;i++){ temp=n-i;while(temp--)printf(" ");for(j=1;j<=i;j++)printf("%d",j);for(j=i-1;j>=1;j--)printf("%d",j);printf("\\n");} for(i=n-1;i>=1;i--){ temp=n-i;while(temp--)printf(" ");for(j...
PASCAL 打印 1 121 12321 1234321 123454321 12345654321
1 121 12321 1234321 123454321 那么代码为 var n,i,j:integer;begin readln(n); \/\/n为行数 for i:=1 to n do begin write('':n-i);for j:=1 to i do write(j);for j:=i-1 downto 1 do write(j);writeln;end;end.如果您只需要在同一排上输出,那么用下面一段代码 var n,...
...为1,第二行为121,第三行为12321,第四行为1234321
Cls Dim i As Integer, j As Integer, N As Integer N = 9 For i = 1 To N 'debug.Print For j = -N To N If j + i < 1 Then Print " ";ElseIf j > i - 1 Then Exit For ElseIf j > 0 Then Print i - j;Else Print j + i;End If Next j Print Next i ...
VB中数字金字塔 样式为:1 121 12321 1234321 以此类推,请问这个程序该...
Private Sub Command1_Click()For i = 1 To 9 Print Spc(9 - i);For j = 1 To i Print Chr(48 + j);Next j For j = i - 1 To 1 Step -1 Print Chr(48 + j);Next j Print Next i End Sub
c语言练习题 怎么样输出 1 121 12321 1234321 12321 121 1
define N 7 define KG abs(N\/2-i)define XH ((N\/2-abs(N\/2-i))*2+1)define SZ XH\/2-abs(XH\/2-j)+1 void main() { int i,j,k;for ( i=0;i<N;i++ ) { for ( j=0;j<KG;j++ ) printf(" ");for ( j=0;j<XH;j++ ) printf("%d",SZ);printf("\\n");}...
用pascal语句打印下列图形: 1 121 12321 1234321 12321 121 1
能用麻溜结贴,不能用继续追问。program PrintTriangle;const LEVEL = 4;var row, col, max, num: Longint;begin max := 0;for row := 1 to LEVEL * 2 - 1 do begin if row <= LEVEL then Inc(max)else Dec(max);Write(' ':LEVEL - max + 1);num := 0;for col := 1 to...