#include stdio.h
目前成都創(chuàng)新互聯(lián)公司已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、洛寧網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
void myitoa(int n,char*str)
{int i,j;
char t;
for(i=0;n;i++)
{str[i]='0'+n%10;
n/=10;
}
str[i]='\0';
for(j=0,i--;ji;j++,i--)
{t=str[i];str[i]=str[j];str[j]=t;}
}
int main()
{ int n;
char s[20];
scanf("%d",n);
myitoa(n,s);
printf("%s\n",s);
return 0;
}
#include stdio.h
#include stdlib.h
#include string.h
#define MAX_N 20
#define MAX_DST 200
char *sub_str_cp(char *src, char *dst, int m)
{
char *dst_o = dst;
if (NULL==src || NULL==dst ||
strlen(src)MAX_N || m1 || mMAX_N)
return NULL;
src += m-1;
while (*(dst++) = *(src++));
return dst_o;
}
char *str_join(char *src1,char *src2,char *dst)
{
char *dst_o = dst;
if (NULL==src1 || NULL==src2 || NULL==dst)
return NULL;
while (*(dst++) = *(src1++));
dst -= 1;
while (*(dst++) = *(src2++));
return dst_o;
}
int ins_sort(int iArr[],int num,int new_one)
{
if (NULL == iArr || num+1 = MAX_DST)
return 0;
int *p = iArr + num - 1;
while (p = iArr new_one *p)
{
*(p+1) = *(p);
p--;
}
*(p+1) = new_one;
return num+1;
}
// 刪除從字符數(shù)組dst中首次出現(xiàn)的字符del_c
char *del_char(char *dst,char del_c)
{
int idx = 0;
char *dst_o = dst;
if (NULL == dst) return NULL;
while ('\0' != *dst)
{
if (*(dst++) != del_c)
*(dst_o + idx++) = *(dst-1);
}
return dst_o;
}
int main()
{
char src[MAX_N+1],src1[MAX_N+1],src2[MAX_N+1];
char dst[MAX_DST+1];
char cA;
int ins_new,num_of_iArr,iA;
int iSort[MAX_DST] = {12,23,32,55,100,101,205,309};
// sub str cp
int m;
printf("subject 1. strcpy\n");
printf("input string(length = %d):",MAX_N);
scanf("%s",src);
printf("copy string from position(1=m=%d):",MAX_N);
scanf("%d",m);
printf("string have been copied:%s\n",sub_str_cp(src,dst,m));
// str join
printf("\nsubject 2. strcat\n");
printf("input string1(length = %d):",MAX_N);
scanf("%s",src1);
printf("input string2(length = %d):",MAX_N);
scanf("%s",src2);
printf("string after joining:%s\n",str_join(src1,src2,dst));
// array sort
printf("\nsubject 3. sorting\n");
num_of_iArr = 8;
printf("oringinal array:\n");
for (iA=0; iAnum_of_iArr; iA++)
printf("%d\t",iSort[iA]);
printf("\ninsert an integer:");
scanf("%d",ins_new);
num_of_iArr = ins_sort(iSort,num_of_iArr,ins_new);
printf("array after sorting:\n");
for (iA=0; iAnum_of_iArr; iA++)
printf("%d\t",iSort[iA]);
printf("\n");
// del elem of array
getchar();
printf("\nsubject 4. del\n");
printf("string:%s\n",dst);
printf("del ? character from above string:");
scanf("%c",cA);
printf("string after deleting %c:%s\n",cA,del_char(dst,cA));
return 0;
}
按照你的要求編寫的C語言程序如下
includestdio.h
int?main()
{
int?a,b;
int?*p=a;
a=30;
printf("a=%d\n",*p);
p=b;
scanf("%d",p);
a=*p+24;
printf("a=%d,b=%d",a,b);
return?0;
}
運(yùn)行結(jié)果
a=30
76
a=100,b=76
#include "stdio.h"
void Sum(int (*p)[3],int total[],int n)//n是總行數(shù)
{
int i,j;
for(i=0;in;i++)
{
for (j=0;j3;j++)
{
total[i]=total[i]+*(*(p+i)+j);
}
}
}
int main()
{
int a[2][3]={};
int total[2]={0,0};
int i,j;
printf("輸入數(shù)組a:\n");
for(i=0;i2;i++)
{
for (j=0;j3;j++)
{
scanf("%d",a[i][j]);
}
}
Sum(a,total,2);
printf("各行的和:\n");
for(i=0;i2;i++)
printf("%d\n",*(total+i));
return 0;
}
#include?"stdio.h"
char?*strins?(char*?s1,?char*?s2)?{
int?a?=?0,?b?=?0;
while?(s1[a++]);
while?(s2[++b]);
while?(a--)?{
s1[a?+?b]?=?s1[a];
}
while?(b--)?{
s1[b]?=?s2[b];
}
return?s1;
}
int?main()?{
char?s1[20];
char?s2[20];
gets(s1);
gets(s2);
printf("c:%s",?strins(s1,s2));
}