±±¾©Ê¯ÓÍ»¯¹¤Ñ§Ôº2026ÄêÑо¿ÉúÕÐÉú½ÓÊÕµ÷¼Á¹«¸æ
²é¿´: 257  |  »Ø¸´: 2

zyj8119

ľ³æ (ÖøÃûдÊÖ)


[½»Á÷] ¡¾ÇóÖú¡¿Ò»¸öC³ÌÐò£¬±¾À´Ó¦¸ÃûÓдíÎ󣬵«ÊÇVCÈÔÈ»»¹ÊÇÓÐ´í¡£¡¾ÒÑÍê½á¡¿

CODE:
#include
#include
#include
#include
#include
int funtest(char (*cp)[],int i)
{ int ix=0,iy=0,ik=0;
  char ca[20]={0},cb[20]={0};
  strcpy(ca,cp[i]);
  rand();
  ik=strlen(ca);
  ix=random(ik);
  iy=random(ik);
  while(iy==ix)iy=random(ik);
  ca[ix]='*';ca[iy]='*';
  printf("The word is:%s,",ca);
  printf("Please input correct word:");
  gets(cb);
  if(strcmp(cb,cp[i])==0)
    return 1;
  else return 0;
}

main()
{   char cs[5][20]={"beautiful","student","china","function","include"};
    int i,ik=0;

randomsize();

i=random(5);

ik=funtest(cs,i);

if(ik)

printf("Right!\n");

else

printf("Wrong!The word is:%s\n",cs)[i];

getch();
}

´íÎóÊÇ£º
--------------------Configuration: jjk - Win32 Debug--------------------
Compiling...
jjk.cpp
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\jjk.cpp(12) : error C2065: 'random' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\jjk.cpp(27) : error C2065: 'randomsize' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\jjk.cpp(33) : error C2109: subscript requires array or pointer type
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\jjk.cpp(35) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.

jjk.obj - 3 error(s), 1 warning(s)

[ Last edited by ÓàÔó³É on 2010-12-13 at 22:05 ]
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

» ÇÀ½ð±ÒÀ²£¡»ØÌû¾Í¿ÉÒԵõ½:

²é¿´È«²¿É¢½ðÌù

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

bignature

ľ³æ (СÓÐÃûÆø)


¡ï ¡ï
zyj8119(½ð±Ò+1):лл²ÎÓë
zyj8119(½ð±Ò+9):ллÌáÐÑ£¡ 2010-12-12 22:02:44
ÓàÔó³É(½ð±Ò+1):лл²ÎÓëÓ¦Öú£¡ 2010-12-13 22:05:22
randomize,randomÊÇborlandC++²ÅÓеġ£
VC¿ÉÒÔÓÃsrandºÍrand
CODE:
#include
#include
#include
#include
#include
int funtest(char** cp,int i)
{
        int ix=0,iy=0,ik=0;
        char ca[20]={0},cb[20]={0};
        strcpy(ca,cp[i]);
        srand( (unsigned)time( NULL ) );
        ik=strlen(ca);
        ix=rand()%(ik+1);
        iy=rand()%(ik+1);
        while(iy==ix)iy=rand()%(ik+1);
        ca[ix]='*';ca[iy]='*';
        printf("The word is:%s,",ca);
        printf("Please input correct word:");
        gets(cb);
        if(strcmp(cb,cp[i])==0)
                return 1;
        else return 0;
}

main()
{
        char* cs[5]={"beautiful","student","china","function","include"};
        int i,ik=0;
        srand( (unsigned)time( NULL ) );
        i=rand()%5;
        ik=funtest(cs,i);
        if(ik)
                printf("Right!\n");
        else
                printf("Wrong!The word is:%s\n",cs[i]);
        getch();
}

[ Last edited by bignature on 2010-12-12 at 22:26 ]
2Â¥2010-12-12 21:57:22
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

zyj8119

ľ³æ (ÖøÃûдÊÖ)


ÒýÓûØÌû:
Originally posted by bignature at 2010-12-12 21:57:22:
randomize,randomÊÇborlandC++²ÅÓеġ£
VC¿ÉÒÔÓÃsrandºÍrand



[code]
#include
#include
#include
#include
#include ...

´ËÌù½áÌù¡£
3Â¥2010-12-12 22:56:59
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ zyj8119 µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] 271·ÖÇóµ÷¼ÁѧУ +3 zph158488£¡ 2026-04-02 3/150 2026-04-03 00:01 by wwytracy
[¿¼ÑÐ] 085600£¬320·ÖÇóµ÷¼Á +6 ´ó²öС×Ó 2026-04-02 6/300 2026-04-02 21:54 by dongzh2009
[¿¼ÑÐ] 260Çóµ÷¼Á +6 ÖìÜÆÁÕ 2026-04-02 6/300 2026-04-02 20:27 by 6781022
[¿¼ÑÐ] 288Çóµ÷¼Á Ò»Ö¾Ô¸¹þ¹¤´ó ²ÄÁÏÓ뻯¹¤ +31 ÂåÉñ¸ç¸ç 2026-03-31 33/1650 2026-04-02 20:00 by tianyyysss
[¿¼ÑÐ] ²ÄÁÏÇóµ÷¼ÁÒ»Ö¾Ô¸¹þ¹¤´ó324 +10 ãÆÐñ¶« 2026-03-28 12/600 2026-04-02 14:37 by olim
[¿¼ÑÐ] 289Çóµ÷¼Á +23 ÐÂʱ´ú²ÄÁÏ 2026-03-27 26/1300 2026-04-02 10:29 by oooqiao
[¿¼ÑÐ] 324Çóµ÷¼Á +5 ÏëÉÏѧÇóµ÷ 2026-04-01 6/300 2026-04-02 10:16 by sanrepian
[¿¼ÑÐ] 322Çóµ÷¼Á +5 ìäÙÒXX 2026-03-31 6/300 2026-04-02 10:08 by Çóµ÷¼Ázz
[¿¼ÑÐ] 085602»¯Ñ§¹¤³Ì268·Ö¶×µ÷¼Á +8 ÔÂÕÕ»¨ÁÖ¡£ 2026-04-01 8/400 2026-04-01 22:08 by Î޼ʵIJÝÔ­
[¿¼ÑÐ] 320·Ö£¬²ÄÁÏÓ뻯¹¤×¨Òµ£¬Çóµ÷¼Á +14 Ò»¶¨Éϰ¶aaa 2026-03-27 18/900 2026-04-01 20:10 by »ý¼«µ÷¼ÁµÄСѧÉ
[¿¼ÑÐ] Ò»Ö¾Ô¸Î÷°²½»´ó²ÄÁÏѧ˶£¨Ó¢Ò»Êý¶þ£©347£¬Çóµ÷¼Áµ½¸ß·Ö×Ó/²ÄÁÏÏà¹Ø×¨Òµ +7 zju51 2026-03-31 9/450 2026-04-01 19:35 by CFQZAFU
[¿¼ÑÐ] 0703Çóµ÷¼Á +4 zizimo 2026-03-31 4/200 2026-04-01 16:04 by yanflower7133
[¿¼ÑÐ] Çóµ÷¼Á +4 ͼ¼ø212 2026-03-30 5/250 2026-04-01 15:32 by ͼ¼ø212
[¿¼ÑÐ] Ò»Ö¾Ô¸Öйú¿ÆÑ§Ôº´óѧ265Çóµ÷¼Á +8 Ìñµ­ye 2026-03-31 9/450 2026-04-01 14:34 by ÄæË®³Ë·ç
[¿¼ÑÐ] ±¾¿Æ211°²È«¹¤³Ì£¬³õÊÔ290·Ö£¬Çóµ÷¼Á +3 2719846834 2026-03-28 3/150 2026-03-31 13:52 by ÈÈÇéɳĮ
[¿¼ÑÐ] 332Çóµ÷¼Á +6 @MZB382400 2026-03-28 6/300 2026-03-30 16:57 by Î޼ʵIJÝÔ­
[¿¼ÑÐ] 356Çóµ÷¼Á +4 gysy?s?a 2026-03-28 4/200 2026-03-29 10:32 by ÌÆãå¶ù
[¿¼ÑÐ] 2026Ä껪ÄÏʦ·¶´óѧ»¶Ó­»¯Ñ§£¬»¯¹¤£¬ÉúÎÉúÒ½¹¤µÈרҵÓÅÐãѧ×Ó¼ÓÈ룡 +3 llss0711 2026-03-28 6/300 2026-03-29 10:26 by llss0711
[¿¼ÑÐ] µ÷¼Á¿¼ÑÐ +3 Íõ½ÜÒ» 2026-03-29 3/150 2026-03-29 08:09 by fmesaito
[¿¼ÑÐ] 330Ò»Ö¾Ô¸Öйúº£Ñó´óѧ »¯Ñ§¹¤³Ì 085602 ÓжÁ²©ÒâÔ¸ Çóµ÷¼Á +3 wywy.. 2026-03-27 4/200 2026-03-28 03:32 by fmesaito
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û