[ create a new paste ] login | about

Link: http://codepad.org/R37Xz8jC    [ raw code | output | fork | 1 comment ]

C, pasted on Sep 14:
#include<stdio.h>
#include<conio.h>

int main()
{
	int i, j, m, n;

	printf("\nNhap m: ");
	scanf("%d", &m);

	// Câu a
	printf("\nNhap n: ");
	scanf("%d", &n);

	for(i = 1; i <= m; ++i)
	{
		for(j = 1; j <= n; ++j) 
		{
			printf("*");
		}
		printf("\n"); //xuong dong khi in xong 1 hang 
	}

	printf( "\n" );

	for(i = 1; i <= m; ++i)
	{
		for(j = 1; j <= n; ++j) 
		{
			if( i == 1 || i == m || j == 1 || j == n )
			{
				printf("*");
				if(j == n)
				printf( "\n" );
			}
			else
				printf(" "); 
		}
	}
	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by Dgls on Feb 17
#include<iostream>
using namespace std;
void In_HCN_Dac(int m, int n){
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++) cout<<" * ";
cout<<endl;
}
}
void In_HCN_Rong(int m, int n){
for (int i=1; i<=n; i++){
if (i==1||i==n){
for (int j=1; j<=m; j++) cout<<" * ";
}
else {
for (int j=1; j<=m; j++){
if (j==1 || j==m) cout<<" * ";
else cout<<" ";
}
}
cout<<endl;
}
}
main(){
cout<<"**Chuong trinh In ra hinh chu nhat co kich thuoc m x n**";
cout<<"\n\t1.Hinh chu nhat dac.";
cout<<"\n\t2.Hinh chu nhat rong.";
int i;
cout<<"\n\nNhap yeu cau cua ban: "; cin>>i;
int m, n;
cout<<"Nhap 2 canh m va n cua hinh chu nhat:\n\tm="; cin>>m;
cout<<"\tn="; cin>>n;
cout<<endl<<endl;
switch(i){
case 1:
In_HCN_Dac(m,n);
break;
case 2:
In_HCN_Rong(m,n);
break;
}
}
reply