/* tao hinh chu nhat n hang, m cot
* * * * *
* *
* *
* *
* * * * *
thuat toan :b1 dau vao:do dai hai canh m,n
b2:tinh toan
tao hai vong lap i=1 toi n va j=1 toi m
vong lap thu 2, j>1va j<m-1; in ra khoang trang
con lai in ra *
b3.ket qua la hinh tren
*/
#include<stdio.h>
int nhap(int &n,int &m) //ham nhap
{
printf("nhap do dai hai canh n,m:");
scanf("%d%d",&n,&m);
}
int main()
{
int a, b;
nhap(a,b);
for(int i=1;i<a;i++){
for(int j=1;j<b;j++)
{
if(j>=2 &&j<m)
{
printf(" 2 ");
}
else printf(" * ");
}printf("\n");
}
return 0;
}
prog.c:16:14: error: expected ')'
int nhap(int &n,int &m) //ham nhap
^
prog.c:16:9: note: to match this '('
int nhap(int &n,int &m) //ham nhap
^
prog.c:16:14: error: parameter name omitted
int nhap(int &n,int &m) //ham nhap
^
prog.c:19:17: error: use of undeclared identifier 'n'
scanf("%d%d",&n,&m);
^
prog.c:19:20: error: use of undeclared identifier 'm'
scanf("%d%d",&n,&m);
^
prog.c:24:8: error: too many arguments to function call, expected 1, have 2
nhap(a,b);
~~~~ ^
prog.c:16:1: note: 'nhap' declared here
int nhap(int &n,int &m) //ham nhap
^
prog.c:28:15: error: use of undeclared identifier 'm'
if(j>=2 &&j<m)
^
6 errors generated.