#include?stdio.h
成都創(chuàng)新互聯(lián)公司專注于企業(yè)成都全網(wǎng)營銷推廣、網(wǎng)站重做改版、赤坎網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)、商城系統(tǒng)網(wǎng)站開發(fā)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)公司、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為赤坎等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
#include?string.h
int?conNumfromStr(char?*,int);
int?main()
{
char?str[21];
printf("輸入20以內(nèi)的字符:");
scanf("%s",str);
printf("字符串中數(shù)字字符個數(shù)為:%d",conNumfromStr(str,strlen(str))?);
return?0;
}
int?conNumfromStr(char?*p,int?len)//計數(shù)字符串中數(shù)字字符的個數(shù)
{
int?i,con=0;
for(i=0;ilen;i++)
{
if(p[i]='0'??p[i]='9')
con++;
}
return?con;
}
#include "stdio.h"int catstr(char *a,char *b,char *c){ int i=0,j=0; for(;*(a+i);i++)*(c+i)=*(a+i); for(;*(b+j);i++,j++)*(c+i)=*(b+j); *(c+i)=*(b+j); return 0;}int lenstr(char *a){ int i=0; for(;*(a+i);i++); return i;}void main(){ char str1[]="Every one is ",str2[]="leaning C.",str12[50]; int len1,len2,len12; len1=lenstr(str1); len2=lenstr(str2); catstr(str1,str2,str12); len12=lenstr(str12); printf("第一個字符串是:\n%s\n長度是:%d\n",str1,len1); printf("第二個字符串是:\n%s\n長度是:%d\n",str2,len2); printf("合并后字符串是:\n%s\n長度是:%d\n",str12,len12); }已經(jīng)運行過。
#define?MAX_NUMBER?80
#includestdio.h
int?main()
{
char?string[MAX_NUMBER],count_char[MAX_NUMBER];
int?count_number[MAX_NUMBER],i,j,char_point=0,temp;
//?init
for(i=0;iMAX_NUMBER;i++)
{
count_char[i]?=?'?';
string[i]?=?'?';
count_number[i]?=?0;
}
i?=?0;
do
{
scanf("%c",string[i]);
temp?=?string[i];
i++;
}while(temp?!=?'\n');
//printf("%s",string);
//?count
for(i=0;iMAX_NUMBER;i++)
{
temp=0;
for(j=0;jMAX_NUMBER;j++)
{
if(string[i]!='?')
{
//printf("0:?%c?1:?%c?\n",string[i],count_char[j]);
if(string[i]?==??count_char[j])
{
count_number[j]++;
temp=1;
}
}
}
if(temp?==?0??string[i]!='?')
{
count_char[char_point]?=?string[i];
count_number[char_point]++;
char_point++;
}
}
temp=0;
do
{
if(temp?==?0)
printf("%c:%d",count_char[temp],count_number[temp]);
else
printf(",%c:%d",count_char[temp],count_number[temp]);
temp++;
}while(count_char[temp]!='\n');
return?0;
}
網(wǎng)頁鏈接