day la code cua minh // cat xen hinh anh.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include "stdio.h" #define true 1; #define false 0; #define left 1; #define right 2; #define bottom 8; #define top 4; //void main (void) //{ struct point { int x; int y; }; struct hcn { point mangdinh[4]; int sodinh; // point diemdau=point diemcuoi; }; struct chia { int xleft; int xright; int ybottom; int ytop; }; //bool namtrong(); int namtrong(point p,int bien,chia hcn1) { switch (bien) { case left: if(p.x return false; break; case right: if(p.x>hcn1.xright) return false; break; case bottom: if(p.y return false; break; case top: if(p.y>hcn1.top) return false; break; } return true;
}
//point 1diemnamtrong1diemnamngoai(point p1,point p2,chia hcn1,int bien); /*point 1diemnamtrong1diemnamngoai(point p1,point p2,chia hcn1,int bien); { point pt; float m; if(p1.x/=p2.x) m=float(p2.y-p1.y)/(p2.x-p1.x); switch(bien) { case left : pt.x=hcn1.xleft; pt.y=p2+(hcn1.xleft-p2.x)*m; case right:
} }*/ //}
int _tmain(int argc, char** argv) { return 0; }
con day la loi minh gap khi debug 1>------ Build started: Project: cat xen hinh anh, Configuration: Debug Win32 ------ 1>Compiling... 1>cat xen hinh anh.cpp 1>c:\users\baongoc\documents\visual studio 2008\projects\cat xen hinh anh\cat xen hinh anh\cat xen hinh anh.cpp(38) : error C2143: syntax error : missing ':' before ';' 1>c:\users\baongoc\documents\visual studio 2008\projects\cat xen hinh anh\cat xen hinh anh\cat xen hinh anh.cpp(38) : error C2143: syntax error : missing ';' before ':'
Sat Apr 09, 2011 9:16 pm
IT Pro
superkid
Giới tính :
Đến từ : cái rốn của vũ trụ!
Join : 06/11/2009
Bài gửi : 500
HUMOR : chơi, nghe nhạc, vẽ, v.v...
Thú cưng .:
Tiêu đề: Re: loi lap trinh voi swith
có 2 lỗi bạn mắc phải trong này. 1>sử dụng #define thì cuối định nghĩa ko dùng ";" chính lí do này khiến chương trình chạy tùm lum ra đó. 2>trong hàm switch của bạn còn 1 số ngoặc chưa dc đóng.có thể là nguyên nhân compiler ko hỉu dc.bạn sửa lại 2 cái này trước đi nhé!
Sat Apr 09, 2011 9:21 pm
IT Pro
superkid
Giới tính :
Đến từ : cái rốn của vũ trụ!
Join : 06/11/2009
Bài gửi : 500
HUMOR : chơi, nghe nhạc, vẽ, v.v...
Thú cưng .:
Tiêu đề: Re: loi lap trinh voi swith
Code:
// cat xen hinh anh.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include "stdio.h" #define true 1 #define false 0
#define left 1 #define right 2 #define bottom 8 #define top 4 //void main (void) //{ struct point { int x; int y; }; struct hcn { point mangdinh[4]; int sodinh; // point diemdau=point diemcuoi; }; struct chia { int xleft; int xright; int ybottom; int ytop; }; //bool namtrong(); int namtrong(point p,int bien,chia hcn1) { switch (bien) { case left: if(p.x) return false; break; case right: if(p.x>hcn1.xright) return false; break; case bottom: if(p.y) return false; break; case top: if(p.y>hcn1.ytop) return false; break; default: return true; } }
//point 1diemnamtrong1diemnamngoai(point p1,point p2,chia hcn1,int bien); /*point 1diemnamtrong1diemnamngoai(point p1,point p2,chia hcn1,int bien); { point pt; float m; if(p1.x/=p2.x) m=float(p2.y-p1.y)/(p2.x-p1.x); switch(bien) { case left : pt.x=hcn1.xleft; pt.y=p2+(hcn1.xleft-p2.x)*m; case right: