[ create a new paste ] login | about

Link: http://codepad.org/9htidGwx    [ raw code | output | fork ]

C, pasted on May 6:
# De Bai : Nhap vao 1 so nguyen n va tinh n! 
/* 

Tác giả: Nguyễn Việt Nam Sơn
Trung tâm đào tạo tin học - Thiết kế phần mềm - Sơn Đẹp Trai: www.SonDepTrai.com

Nguồn source code này Tôi viết vào năm 2012 lúc mới bắt đầu học lập trình C/C++ nên một số cách sẽ không được tối ưu - Bạn chỉ nên dùng trên tinh thần tham khảo thôi nhé.
Mong giúp đỡ được Bạn trên con đường Học Lập Trình.
TẤT CẢ VÌ SỰ THÀNH CÔNG CỦA BẠN

*/
.data
	tb1:.asciiz "Nhap vao so nguyen n = "
	tb2:.asciiz "n! = "
	n:.word 0
.text
main:
	# Xuat tb1
	li $v0,4
	la $a0,tb1
	syscall
	
	# Nhap so nguyen n
	li $v0,5
	syscall
	
	# Luu tru vao n
	sw $v0,n
	
	# Khoi tao gia tri vong lap
	li $t0,1 # Tich = 1 
	li $t1,1 # i = 1
	lw $t2,n # Chep gia tri cua n vao thanh ghi tam $t2 

Lap:
	# Qua trinh lap i se chay den = n thi dung lai,neu i > n <=> n - i < 0 => ket thuc lap
	sub $t3,$t2,$t1 
	bltz $t3,KetThucLap
	mult $t0,$t1 #  Tich * i
	mflo $t0 # Tich = Tich * i 
	addi $t1,$t1,1 # i = i + 1 
	j Lap # Lap lai qua trinh tren
	
KetThucLap:
	# Xuat tb2
	li $v0,4
	la $a0,tb2
	syscall
	
	move $a0,$t0 # Ghi gia tri tong trong thanh ghi tam $t0 vao thanh ghi $a0 .
	
	# Xuat Tong
	li $v0,1
	syscall
	
Exit:
	li $v0,10
	syscall


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Line 2: error: invalid preprocessing directive #De
Line 12: error: expected identifier or '(' before '.' token
Line 3: error: invalid preprocessing directive #Xuat
Line 3: error: invalid preprocessing directive #Nhap
Line 3: error: invalid preprocessing directive #Luu
Line 3: error: invalid preprocessing directive #Khoi
Line 31: error: stray '#' in program
Line 32: error: stray '#' in program
Line 33: error: stray '#' in program
Line 3: error: invalid preprocessing directive #Qua
Line 39: error: stray '#' in program
Line 40: error: stray '#' in program
Line 41: error: stray '#' in program
Line 42: error: stray '#' in program
Line 3: error: invalid preprocessing directive #Xuat
Line 50: error: stray '#' in program
Line 3: error: invalid preprocessing directive #Xuat


Create a new paste based on this one


Comments: