CÒÅÁôµÄ½á¹¹Ìøת
±±º£
1) goto
goto Ö»ÄÜÔÚÒ»¸öº¯ÊýÄÚÌøת¡£½¨ÒéÉÙÓã¬Ê¹µÃ³ÌÐòά»¤ÆðÀ´ÈÝÒ׳ö´í£»µ«ÊÇ£¬ÔÚÓжà¸öÑ»·Çé¿öÏÂÌøת£¬ÓÐʱÓÃgoto¿ÉÒÔʹµÃÎÊÌâ±äµÃ¼òµ¥¡£
class A
{
public:
A(){}
~A(){}
};
int main()
{
{
A a;
goto Label1;
}
Label1:
cout<<”end”<<endl;
return 0;
}
2) setjmp/longjmp
·Ç¾Ö²¿ÓòÌøת(nonlocal goto)£¬¿ÉÓÃÓÚÔÚ²»Í¬º¯ÊýÄÚÌøת£¬²½ÖèÈçÏ£º
l include <setjmp.h>
l jmp_buf JumpBuffer
//ÌøתµÄλÖýṹ
l setjmp(JumpBuffer)
±£´æµ±Ç°µÄλÖ㬽«À´Ìøתµ½ÕâÀï
l longjmp(JumpBuffer, ÕûÊý)
jmp_buffer jmpbuf;
void Func()
{
cout << “ get in “ <<endl;
A a;
longjmp(jmpbuf, 1);
cout << “ never get here “<<endl;
}
int main()
{
cout << “ get in main “ <<endl
if( setjmp (jmpbuf ) == 0 )
{
cout<<”set lable”<<endl;
Func();
}
else
{
cout<<” jmp to here”<<endl;
}
}
Ïà¹ØÎĵµ£º
1.ÕâÑùµÄ³õʼ»¯ÓÐʲôÎÊÌ⣿char *p = malloc(10); ±àÒëÆ÷Ìáʾ“·Ç·¨³õʼʽ” ÔÆÔÆ¡£
´ð:Õâ¸öÉùÃ÷ÊǾ²Ì¬»ò·Ç¾Ö
²¿±äÁ¿Â𣿺¯Êýµ÷ÓÃÖ»ÄܳöÏÖÔÚ×Ô¶¯±äÁ¿(¼´¾Ö²¿·Ç¾²Ì¬±äÁ¿) µÄ³õʼʽÖС£
ÒòΪ¾²Ì¬±äÁ¿µÄµØÖ·±ØÐëÔÚ±àÒëµÄ¹ý³ÌÖоÍÈ·¶¨ÏÂÀ´¶ømalloc()Éê
ÇëµÄÄÚ´æµØÖ·ÊÇÔÚÔËÐÐʱȷ¶¨µÄ¡£
2. *p++ ×ÔÔöp »¹ÊÇp ËùÖ ......
ÒªÈà Eclipse ¿ÉÒÔ¿ª·¢ C/C++ ³Ìʽ£¬Òª¹ÒÉÏ CDT ²Å¿ÉÒÔ¡£
Ê×ÏÈÒªÏÂÔØCDT
CDTµÄ×îа汾ÊÇ 3.1.0£¬ËüÖ§³Öeclipse3.2.0£¬ÆäÏÂÔصØÖ·£ºhttp://download3.eclipse.org/tools/cdt/releases/callisto/dist/3.1.0/£¬»òÕßÊǵ½http://www.eclipse.org/cdt/downloads.phpÏÂÔØÆäËü° ......
ºÃ¾ÃÒÔÇ°×öµÄÒ»¸ö³ÌÐò£¬Ì°ÐIJßÂÔʵÏÖ±³°üÎÊÌ⣬cʵÏÖ¡£
×ܽáÔÚÕâÀÒÔ±¸ÒÔºóºÍ±ðÈ˲éÕÒ¡£
//±³°üÎÊÌâ
#include "stdio.h"
#define MAX 10
void main()
{
int w[MAX]={0,10,130,15,60,25}; //´æ·ÅÖÊÁ¿
int v[MAX]={0,30,5,10,20,25}; //´æ·Å¼ÛÖµ
flo ......
#include<stdio.h>
#define N 8
void input(int n,int p[N][N])
{
int i,j;
for(i=0;i<n;i++)
{
printf("please input the %d line:\n",i+1);
for(j=0;j<n;j++)
{
scanf("%d",&p[i][j]);
}
}
}
void output(int n,int p[N][N])
......
¡¶Cר¼Ò±à³Ì¡·Ñ§Ï°×ܽá2
ת×Ô £º http://blog.chinaunix.net/u2/87570/showart_2120069.html
±àÒëÆ÷×öÁËЩʲô
ͼ1£º±àÒëÆ÷ͨ³£·Ö¸î³É¼¸¸ö¸üСµÄ³ÌÐò
¾²Ì¬Á´½ÓÓ붯̬Á´½Ó
  ......