Çë½Ì¸ßÊÖÃǽâÒ»µÀc³ÌÐò¡£ - C/C++ / CÓïÑÔ
±àÒ»¸öc³ÌÐò,ÏȺóÊäÈëÒ»¸ö×Ö·ûºÍÒ»¸ö×Ö·û´®,ͳ¼ÆÇ°Ò»¸ö×Ö·ûÔÚ×Ö·û´®ÖгöÏֵĸöÊý¡£
ÕâÑùµÄÌâÄ¿¶¼²»×Ô¼º×ö£¬ºÎ±Øѧ±à³Ì£¿
C/C++ code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char ch;
char str[100];
int count=0,i;
printf("ÊäÈëÒ»¸ö×Ö·û:");
scanf("%c",&ch);
printf("ÊäÈëÒ»¸ö×Ö·û´®:");
scanf("%s",str);
for(i=0;i<strlen(str);i++)
if(ch == str[i])
count++;
printf("×Ö·û³öÏֵĸöÊý:%d\n",count);
return 0;
}
Â¥Ö÷ÈÈ°®±à³Ì£¬Ôõô²»×Ô¼º½â¾öÕâ¸öÎÊÌâ°¡
Õâ¸ö»¹ÊÇ×Ô¼ºÐ´Ð´°É¡£¡£²»ÒªÌ«¼òµ¥¡£²»»á¾ÍºÃºÃ»ØÈ¥¿´Óï·¨Êé
2Â¥µÄ´úÂë¿ÉÒÔÊÔÊÔ£¬µ«ÔÚ
scanf("%c",&ch);
ºó¼ÓÉÏgetchar();½ÓÊջسµ×Ö·û¡£
lzÄãÌ«À×ÈËÁË¡£¡£¡£¡£¼ÓÓÍ°¡
#include <stdio.h>
#include <string.h>
#defne MAXSIZE 100
int main()
{
int i=0,num=0;
char ch,str[MAXSIZE];
//ÊäÈë×Ö·û
printf("Please input a char:");
scanf("%c",&ch);
getchar();//¹ýÂËÊäÈëµÄ»Ø³µ
//ÊäÈë×Ö·û´®
printf("Please input a string:");
gets(str);
//ÅжÏ×Ö·û³öÏֵĴÎÊý
while(i++<strlen(str))
num += (str[i]==ch?)1:0;
printf("the num is : %d\n"
Ïà¹ØÎÊ´ð£º
¹«Ë¾¿ª·¢Ò»¸ö´¥ÃþÆÁ³ÌÐò£¬ÎÒ¸ºÔðµÄÒ»¿é£¬ÊµÏÖÕâÑùÒ»¸ö¹¦ÄÜ£¬µ±Êó±êµã»÷´°¿ÚÖÐͼƬ£¨Ò»ÕÅͼ·Ö³É¼¸²¿·Ö£©µÄÆäÖÐÒ»²¿·Öʱ£¬½«Õⲿ·ÖͼƬ½ØÈ¡³öÀ´£¬µ¯³öеĴ°¿Ú£¬½«½ØÈ¡³öµÄͼƬÏÔʾ³öÀ´¡£ÎÒʹÓÃRectangeÀà¿ØÖÆÁË·µ»Ø£¬ ......
ÔھƵê¹ÜÀíϵͳÖÐ,ÓÐÒ»¸ö¶ÔÄÚµÄϵͳ,¹©Ç°Ì¨·þÎñÔ±ºÍ¾ÀíʹÓÃ
»¹ÓÐÒ»¸ö¾ÍÊǶÔÍâ,Èÿͻ§¿ÉÒÔÔÚÍøÉÏÔ¤¶©·¿¼ä,
ËüÃÇÖ®¼äÊÇÔõôͨѶµÄ.?µ±ÎÒÌá½»Ô¤¶©·¿¼äÐÅÏ¢µÄʱºò,
ÔÚ¶ÔÄÚµÄϵͳÖÐ,ÈçºÎÖªµÀÎÒÒѾÌá½»ÁËÐÅÏ¢¹ýÈ¥.Ê¹Ç ......
ÎÒ¸Õ°ÑÌ·ºÆÇ¿µÄµÚÈý°æµÄÊéѧÍ꣬ÎÒÖªµÀµÄÓÐC++£¬CºÍÖ¸Õë CȱÏݺÍÏÝÚå Cר¼Ò±ä³É£¬»¹ÓÐÊý¾Ý½á¹¹£¬ÎÒÏëÎÊÎÊÎÒÓ¦¸ÃÒÔʲô˳ÐòÀ´Ñ§ÄØ
CȱÏݺÍÏÝÚå Cר¼Ò±à³Ì
Êǽø½×µÄ£¬²»Óü±×Å¿´
ÖÁÓÚ
CºÍÖ¸Õë
Äã²»Àí½âÖ ......
ÈçºÎ½«Ò»¸öListBoxÖеÄÊý¾Ý´æÔÚÊý¾Ý¿âÖеÄÒ»¸ö×Ö¶ÎÏÂÃ棬²¢ÇÒÿÌõ¼Ç¼µÄ×Ö·û´®¸öÊý²»Ò»¶¨ ÒÔ¼°ÈçºÎ´ÓÊý¾Ý¿âÖжÁÈ¡¸ÃListBoxÖеÄËùÓмǼ
C/C++ code:
//´æÈëÊý¾Ý¿â
void __fastcall TForm1::Button5Click(TO ......