Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ ±ê×¼º¯ÊýÓ¦ÓÃС½á Ö® Ëæ»úº¯Êý

×Ô´Ó½Ó´¥ÕâÃÅÓïÑÔµ½ÏÖÔÚÓÐÒ»¸ö¶àÐÇÆÚµÄʱ¼äÁË£¬ËäÈ»ÒÔºóµÄ·»¹ºÜ³¤£¬»áÓöµ½¸÷ÖÖÀ§ÄÑ£¬µ«Ö»ÒªÓÐÄÍÐĺÍÒãÁ¦£¬»¹Òª½Å̤ʵµØµÄ´òºÃ»ù´¡£¬¾ÍÒ»¶¨ÄÜÓг¤Í¾µÄ½ø²½£¬ºÇºÇ£¬Ï£ÍûÔÚÕâÀïµÄÿһ¸öÈ˶¼ºÍÎÒÒ»Æð¼ÓÓÍ£¬²»¶Ï½ø²½¡£
Ëæ»úº¯Êý¶ÔÿÖÖ±à³ÌÓïÑÔÀ´Ëµ¶¼ÊÇÒ»¸ö²»¿ÉȱÉٵĻ·½Ú£¬ÄÇôÔÚC++ÖÐËüÊÇÈçºÎÓ¦Óõģ¬ÕâÀïΪÁË·½±ãÀí½â£¬¶ÔÒÔÇ°¿´¹ýµÄ¼¸ÆªÎÄÕÂ×öÒÔÏÂ×ܽá:
I ) ±¾µØC++¿ØÖÆ̨ӦÓóÌÐò
C++±ê×¼º¯Êý¿âÌṩһËæ»úÊýÉú³ÉÆ÷rand£¬rand()º¯Êý²»½ÓÊܲÎÊý£¬Ä¬ÈÏÒÔ1ΪÖÖ×Ó£¨¼´Æðʼֵ£©¡£ Ëæ»úÊýÉú³ÉÆ÷×ÜÊÇÒÔÏàͬµÄÖÖ×Ó¿ªÊ¼£¬ËùÒÔÐγɵÄαËæ»úÊýÁÐÒ²Ïàͬ¡£Èç¹ûÐèÒª²úÉúµÄËæ»úÊý²»ÐèÒªÉ趨·¶Î§µÄ»°£¬ÓÃrand()¾ÍÐС£
²»ÒªÍü¼ÇÊÂÏȶ¨Òå°üº¬rand()µÄÍ·Îļþ #include<stdio.h>ºÍ#include<stdlib.h>¡£ÈçÀý1 #include<stdio.h>
#include<stdlib.h>
void main()
{
for(int i=0;i<10;i+)
printf("%d\n",rand());
}

¾ßÌåÓ¦ÓÃÈ磬Ҫ²úÉú0µ½10µÄËæ»úÊý rand()%(10 + 1); ¼´ rand()%11;  Èô1µ½10 : 1 + rand()%11;ÒÔ´ËÀàÍÆ aµ½b :            a + rand()%(b - a + 1);
ÔËÐкó»á·¢ÏÖ£¬Ã¿´ÎÔËÐгÌÐò²úÉúµÄËæ»úÊý¶¼ÊÇÒ»ÑùµÄ£¬ÒòΪÈç¹ûÖÖ×ÓÏàͬµÄ»°£¬²úÉúµÄαËæ»úÊýÁÐÒ²Ïàͬ¡£ÈôÒª²úÉúÿ´Î²»Í¬µÄËæ»úÊý£¬¿ÉÒÔʹÓÃC++ÖÐÁíÒ»º¯Êýsrand£¨£©£¬¿ÉÒÔÖ¸¶¨²»Í¬µÄÊý£¨ÎÞ·ûºÅÕûÊý±äÔª£©ÎªÖÖ×Ó¡£
ÓÃʱ¼äÀ´×÷ΪËæ»úÊýÉú³ÉÆ÷µÄÖÖ×ӱȽÏÀíÏ룬timeµÄֵÿʱÿ¿Ì¶¼²»Í¬¡£ËùÒÔÖÖ×Ó²»Í¬£¬ËùÒÔ£¬²úÉúµÄËæ»úÊýÒ²²»Í¬¡£
ÈçÀý2 // C++Ëæ»úº¯Êý£¨VC program£©
#include <stdio.h>
#include <iostream>
#include <time.h>
using namespace std;
#define MAX 100
int main(int argc, char* argv[])
{
srand( (unsigned)time( NULL ) );//srand()º¯Êý²úÉúÒ»¸öÒÔµ±Ç°Ê±¼ä¿ªÊ¼µÄËæ»úÖÖ×Ó.Ó¦¸Ã·ÅÔÚforµÈÑ­»·Óï¾äÇ°Ãæ ²»È»ÒªºÜ³¤Ê±¼äµÈ´ý
for (int i=0;i<10;i++)
cout<<rand()%MAX<<endl;//MAXΪ×î´óÖµ£¬ÆäËæ»úÓòΪ0~MAX-1
¡¡¡¡ return 0;
}
 
ÕâÑù¾Í¿ÉÒÔÿ´ÎµÃµ½0µ½Ä³¸ö·¶Î§²»Í¬Ëæ»úÊý£¬ÀýÌâÖÐͬÑùÐèÒªÏȶ¨Òå°üº¬Ê±¼äº¯Êýtime()µÄÍ·Îļþ¡£


Ïà¹ØÎĵµ£º

object c ÄÚ´æ¹ÜÀí

   ¿´ÁËϹٷ½ÎĵµµÄ¹ØÓÚobject c µÄÄÚ´æ¹ÜÀí,×ܽáÏÂ:
 
    ÔÚiphoneÖÐobject c  ÖеÄÄÚ´æ¹ÜÀíÊÇͨ¹ý¼ÆÊýÆ÷À´¹ÜÀíµÄ,ÿ¸ö¶ÔÏóÄÚ²¿¶¼ÓÐÒ»¸ö¼ÆÊýÆ÷.н¨Ò»¸ö¶ÔÏó,»òÕßÕâ¸ö¶ÔÏó±»ÆäËû¶ÔÏóÒýÓÃ,¶à»áʹ¼ÆÊýÆ÷¼Ó1.Retain Ôö¼Ó¼ÆÊýÆ÷Öµ release ¼õÉÙ¼ÆÊýÆ÷Öµ.µ±¼ÆÊýÆ÷Ϊ0ʱ¶ÔÏó¾Ídeall ......

¿ØÖÆ̨³ÌÐòCtrl +C Í˳ö

[DllImport("kernel32.dll",SetLastError=true)]
[return: MarshalAs( UnmanagedType.Bool )]
static extern bool AllocConsole();
[DllImport("kernel32.dll",SetLastError=true)]
[return: MarshalAs( UnmanagedType.Bool )]
static extern bool FreeConsole();
// Delegate type to be used as the Handler Routin ......

c++µ÷ÓÃcʱ»Øµ÷º¯ÊýµÄ´¦Àí

      ÔÚc++µ÷ÓÃc³ÌÐòʱ£¬»Øµ÷º¯ÊýÊDz»ÄÜÖ±½ÓʹÓõģ¬ÒÔc++µ÷ÓÃcµÄGtkº¯ÊýΪÀý£¬ ±ÈÈ磬ÔÚg_idle_add (init, NULL);
Õâ¾ä»°ÖУ¬Ò»µ©idle¾Í»áµ÷Óú¯Êýinit(), Õâ¸öinit()»¹»á¶ÔÀàµÄ³ÉÔ±±äÁ¿½øÐд¦Àí¡£
Õâʱ£¬¼ÙÈç°Ñinit()¼òµ¥µØ¶¨ÒåΪÀàµÄÆÕͨ³ÉÔ±º¯Êý¾Í»á³öÏÖÀàÐͲ»Æ¥ÅäµÄ´íÎó£¬ÒòΪg_idle_add ......

Linux ϱàÒëhello world µÄC ÓïÑÔ³ÌÐò

±¾À´ÎÒÓõÄÊÇÕâÑùµÄ³ÌÐò
# include <iostream.h>
int main(void)
{
  int i,j;
  j=0;
  i=j+1;
  cout<<"hello world!"<<endl;
  cout<<"the result is"<<i<<endl;
  return 0;
}
ÀûÓÃg++ -o test test.cpp¡£µ«ÊÇÕâÑùÊÇÓдíÎóµÄ£¬ÌáʾÎÞ·¨´ ......

CÓïÑÔдµÄ×Ö½Ú²éѯÆ÷£¨³õѧCÁ·ÊÖÓã©

ÓÃCÓïÑÔдµÄÒ»¸ö¼òµ¥µÄ×Ö½ÚÐͲéѯÆ÷£¬Ö÷Òª¹¦ÄÜÊÇʵÏÖ¶Ô        signed int        float        unsigned int        double        s ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ