¿ìËÙÒµÎñͨµÀ

C/C++ÖеĽṹÌå

×÷Õß ØýÃû¼¼Êõ À´Ô´ ³ÌÐòÉè¼Æ ä¯ÀÀ ·¢²¼Ê±¼ä 2012-06-30
??¨°???¨´?¦Ì¨°???¡ê?¡ä?¦ÌY?¨¢11¨°y¨®?¦Ì?¨¤y¡Á¨®?¡ê

¨¤?¨®?¨°y¨®?¡ä?¦ÌY¦Ì?o?¡ä|o¨¹?¨¤¡ê??¨¹¦Ì?D¡ì?¨ºo¨ª?????¨¤2??T??¡ê?¦Ì?¨°y¨®?¦Ì?2¨´¡Á¡Â¡¤?¨º?o¨ª?¦Ì¡ä?¦ÌY??o?¨°??¨´¡ê?????¨®?¨º????¦Ì?¡Â¨¦?¨®?¨°y¨®??¨¦¨°?¡Á?¦Ì?3¨¬D¨°¦Ì?¨°¡Á?¨¢o¨ª¨°¡Á2¨´¡Á¡Â¡ê??¨¹¦Ì?¨®?¨º?¨®¨¨???¨²?¨¢11o¨ª¡ä¨®¦Ì?¨º¡Ào¨°¡ê?¡À¨¹?a¡ä?¦ÌY?¨¢11¡À?¨¢?o¨¹¡ä¨®¦Ì??¦Ì¡ê??¨²¨º??¨²¡ä?¡ê?¨¬¨¢??D¡ì?¨º?¡ê

#include <iostream>
#include <string>
using namespace std;
struct test
{
char name[10];
float socre;
};
void print_score(test &pn)//¨°??¨¢11¡À?¨¢???DD¡ä?¦ÌY
{
cout<<pn.name<<"|"<<pn.socre<<endl;
}
void main()
{
test a[2]={{"marry",88.5},{"jarck",98.5}};
int num = sizeof(a)/sizeof(test);
for(int i=0;i<num;i++)
{
print_score(a[i]);
}
cin.get();
}

¨¦????¨°???¦Ì?¡Â¨¢?¨°¡Á¨®?¨°y¨®????¨¢11¨¬???DD2¨´¡Á¡Â¦Ì?¨®?¨º?¡ê??????¨°????¦Ì???¡À¨¨¨¢???¨¤y3¨¬¡ê???¨°?2?¡¤???1?¨®¨²D¡ì?¨º¦Ì??¨º¨¬a?¡ê

//-------------------------------------Àý³Ì1---------------------------------
#include <iostream>
#include <string>
using namespace std;
struct test
{
char name[10];
float socre;
};
void print_score(test &pn)
{
cout<<pn.name<<"|"<<pn.socre<<endl;
}
test get_score()
{
test pn;
cin>>pn.name>>pn.socre;
return pn;
}
void main()
{
test a[2];
int num = sizeof(a)/sizeof(test);
for(int i=0;i<num;i++)
{
a[i]=get_score();
}
cin.get();
for(int i=0;i<num;i++)
{
print_score(a[i]);
}
cin.get();
}
//-------------------------------------Àý³Ì2---------------------------------
#include <iostream>
#include <string>
using namespace std;
struct test
{
char name[10];
float socre;
};
void print_score(test &pn)
{
cout<<pn.name<<"|"<<pn.socre<<endl;
}
void get_score(test &pn)
{
cin>>pn.name>>pn.socre;
}
void main()
{
test a[2];
int num = sizeof(a)/sizeof(test);
for(int i=0;i<num;i++)
{
get_score(a[i]);
}
cin.get();
for(int i=0;i<num;i++)
{
print_score(a[i]);
}
cin.get();
}

Àý³Ì2µÄЧÂÊÒªÔ¶¸ß¹ýÀý³Ì1µÄÔ­ÒòÖ÷ÒªÓÐÒÔÏÂÁ½´¦£º

µÚÒ»:

Àý³Ì1ÖеÄ

test get_score()
{
test pn;
cin>>pn.name>>pn.socre;
return pn;
}

µ÷ÓõÄʱºòÔÚÄÚ²¿ÒªÔÚÕ»¿Õ¼ä¿ª±ÙÒ»¸öÃûΪpnµÄ½á¹¹Ìå±äÁ¿£¬³ÌÐòpnµÄʱºòÓÖÔÙ´ÎÔÚÕ»ÄÚ´æ¿Õ¼äÄÚ×Ô¶¯Éú³ÉÁËÒ»¸öÁÙʱ½á¹¹Ìå±äÁ¿temp£¬ÔÚÇ°ÃæµÄ½Ì³ÌÖÐÎÒÃÇÒѾ­Ëµ¹ý£¬ËüÊÇÒ»¸öcopy£¬¶øÀý³Ì2Öеģº

void get_score(test &pn)
{
cin>>pn.name>>pn.socre;
}

ȴûÓÐÕâÒ»¹ý³Ì£¬²»¿ª±ÙÈκÎеÄÄÚ´æ¿Õ¼ä£¬Ò²Ã»ÓÐÈκÎÁÙʱ±äÁ¿µÄÉú³É¡£

µÚ¶þ:

Àý³Ì1ÔÚmian()ÖУ¬±ØÐë¶Ô·µ»ØµÄ½á¹¹Ìå±äÁ¿½øÐÐÒ»´Î½á¹¹Ìå±äÁ¿Óë½á¹¹Ìå±äÁ¿Ö±½ÓµÄÏ໥¸³Öµ²Ù×÷¡£

for(int i=0;i<num;i++)
{
a[i]=get_score();
}

¶øÀý³Ì2ÖÐÓÉÓÚÊÇͨ¹ýÄÚ´æµØÖ·Ö±½Ó²Ù×÷£¬ËùÒÔÍêȫûÓÐÕâÒ»¹ý³Ì£¬Ìá¸ßÁËЧÂÊ¡£

for(int i=0;i<num;i++)
{
get_score(a[i]);
}

º¯ÊýÒ²ÊÇ¿ÉÒÔ·µ»Ø½á¹¹ÌåÓ¦Óõģ¬Àý×ÓÈçÏ£º

#include <iostream>
#include <string>
using namespace std;
struct test
{
char name[10];
float socre;
};
te

ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!

·ÖÏíµ½£º ¸ü¶à
«Ë¾ÔÚÔËÓªÖеIJßÂÔ" target="_blank">ÍøÂçÓªÏú¹«Ë¾ÔÚÔËÓªÖеIJßÂÔ
  • iBATIS 3ÄÚµÄÐÂÌØÐÔ£º½«iBATISÓÃ×÷Ó¦ÓóÌÐòÄÚµÄÒ»Öֳ־ÿò¼Ü - ±à³ÌÈëÃÅÍø
  • Photoshop»æÖƸ߹âË®¾§ÖʸÐË®¾§Æ»¹û
  • Copyright ©1999-2011 ÏÃÃÅÁèÖڿƼ¼ÓÐÏÞ¹«Ë¾ ÏÃÃÅÓÅͨ»¥Áª¿Æ¼¼¿ª·¢ÓÐÏÞ¹«Ë¾ All rights reserved

    µØÖ·(ADD)£ºÏÃÃÅÈí¼þÔ°¶þÆÚÍûº£Â·63ºÅ701E£¨¶«ÄÏÈÚͨÅÔ£© Óʱà(ZIP)£º361008

    µç»°£º0592-5908028 ´«Õ棺0592-5908039 ×ÉѯÐÅÏ䣺web@lingzhong.cn ×ÉѯOICQ£º173723134

    ¡¶ÖлªÈËÃñ¹²ºÍ¹úÔöÖµµçÐÅÒµÎñ¾­ÓªÐí¿ÉÖ¤¡·ÃöB2-20100024  ICP±¸°¸:ÃöICP±¸05037997ºÅ