十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
#include?stdio.h
創(chuàng)新互聯(lián)建站始終堅持【策劃先行,效果至上】的經(jīng)營理念,通過多達(dá)十年累計超上千家客戶的網(wǎng)站建設(shè)總結(jié)了一套系統(tǒng)有效的全網(wǎng)推廣解決方案,現(xiàn)已廣泛運(yùn)用于各行各業(yè)的客戶,其中包括:生料攪拌車等企業(yè),備受客戶贊許。
#include?string.h
//?將str字符以spl分割,存于dst中,并返回子字符串?dāng)?shù)量
int?split(char?dst[][80],?char*?str,?const?char*?spl)
{
int?n?=?0;
char?*result?=?NULL;
result?=?strtok(str,?spl);
while(?result?!=?NULL?)
{
strcpy(dst[n++],?result);
result?=?strtok(NULL,?spl);
}
return?n;
}
int?main()
{
char?str[]?=?"what?is?you?name?";
char?dst[10][80];
int?cnt?=?split(dst,?str,?"?");
for?(int?i?=?0;?i??cnt;?i++)
puts(dst[i]);
return?0;
}
這個是用c++寫的不過和c的原理也差不多我運(yùn)行過了,有什么問題再問吧,c不知道能否運(yùn)行,不過現(xiàn)在c/c++程序設(shè)計試驗系統(tǒng)通常都有嵌套c++,你打開c界面時單擊vc6.0創(chuàng)建一個項目運(yùn)行就可以了。
#include iostream
using namespace std;
char** split(char p[],char c,int k)
{
int i,m,j;
char **q;
q=(char**)new char*[k];
for(i=0;ik;i++)
q[i]=(char*)new char*[20];
i=0;
j=0;
m=0;
while(p[i])
{
if(p[i]!=',')
{
q[j][m++]=p[i++];
}
else
{
q[j][m]='\0';
j++;
m=0;
i++;
}
}
q[k-1][m]='\0';
for(i=0;i4;i++)
{
coutq[i];
coutendl;
}
return q;
}
void main()
{ int k;
char p[]="ab,cde,efgh,ghi32";
char c=',';
int i=0,j=0,m=0;
while(p[i])
{
if(p[i]==',')
j++;
i++;
}
j=j+1;//接受到底有多少個單詞在分割后通過逗號去判斷
k=j;
char**q=split(p,c,k);
printf("\n");
for(i=0;i4;i++)
{
coutq[i];
coutendl;
}
}
#include
int?main()
{
int?x,y;
scanf("%d",x);
if(0xx10)?y=3*x+2;
else
{if(x=0)?y=0;
else
{if?(x0)?y=x*x;
else?printf("go?die\n");
}
}
printf("%d",y);
return?0;
}該程序的分段函數(shù)如下:
f(x)=3x+2? (0x10)
f(x)=1???????? (x=0)
f(x)?=?x*x??? (x0)
#include stdio.h
#include math.h
void main()
{
float x;
double y;
printf("Please input the value of x:");
scanf("%f",x);
if(x=-10x=4)
{
y=fabs(x-2);
printf("y=%.2f\n",y);
}
else if(x=5x=7)
{
y=x+10;
printf("y=%.2f\n",y);
}
else if(x=8x=12)
{
y=pow(x,4);
printf("y=%.2f\n",y);
}
else
printf("No answer\n");
}