注册 登录
编程论坛 新人交流区

编写一个三角行如图

ltdtfking 发布于 2007-10-09 16:41, 598 次点击
a
b b b
c c c c c一至到g程序是怎么表示啊能给我说说吗?
5 回复
#2
vtgww2007-10-09 16:59
a
b b b
c c c c c

是不是要输出上面的图形?

LZ说清楚点哦..
#3
没有注册2007-10-09 16:59
#4
moximon2007-10-09 18:32

刚好有个想法,于是现在开始磨刀写.......>___________<

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; triangle.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model stdcall, flat
option casemap: none

include windows.inc
include kernel32.inc
include user32.inc
includelib kernel32.lib
includelib user32.lib

.data
szBuffer db 512 dup(?)
szCaption db "显示三角形",0

.code
main:
pushad
mov edi, offset szBuffer
mov al, 41h ;41=A
mov edx, 1

@@: mov ecx, edx
rep stosb
add edx, 2
;*****************************
push ax
mov ax, 0d0ah ;0d0ah=Enter
stosw
pop ax
:*****************************
inc al
cmp al, 47h ;47=G
jz @Display
jmp @b
popad

@Display: invoke MessageBox, NULL, offset szBuffer, offset szCaption, MB_OK
invoke ExitProcess, NULL
end main

编译链接好在对话框中显示
a
bbb
ccccc
ddddddd
eeeeeeeee
.....

[此贴子已经被作者于2007-10-9 18:47:34编辑过]

#5
Standford2007-10-09 19:26
#include<iostream>
using namespace std;
void main()
{
int i,j,n=7;
char letter='a';
for(i=1;i<=n;i++)
{
for(j=1;j<=30;j++)
cout<<' ';
for(j=1;j<=(14-2*i);j++)
cout<<' ';
for(j=1;j<=(2*i-1);j++)
cout<<(char)(letter+i-1)<<' ';
cout<<endl;
}
}
运行结果是:
a
b b b
c c c c c
d d d d d d d
e e e e e e e e e
f f f f f f f f f f f
g g g g g g g g g g g g g
Press any key to continue
是不是这种形式?
#6
小刚刚2007-10-09 20:13
1