指针

来源:互联网 发布:数据分析的统计基础 编辑:程序博客网 时间:2024/05/10 17:19

今天主要看有关指针的原理部分,并未做太多的习题,总之感觉指针部分有难度

/*#include<stdio.h>

main()
{
int a=10,b=20,x,*pa,*pb;
pa=&a;
pb=&b;
printf("%d,%d,%d,%d\n",a,b,*pa,*pb);
x=*pa;
*pa=*pb;
*pb=x;
printf("%d,%d,%d,%d\n",a,b,*pa,*pb);
}*/
/*#include<stdio.h>
main()
{
int a=10,b=20,*p,*pa=&a,*pb=&b;
printf("%d,%d,%d,%d\n",a,b,*pa,*pb);
p=pa;
pa=pb;
pb=p;
printf("%d,%d,%d,%d\n",a,b,*pa,*pb);
}*/
/*#include<stdio.h>
int *swap(int *a,int *b)
{
int *p;
p=a;
a=b;
b=p;
return(a);
}
main()
{
int x=3,y=4,z=5;
swap(swap(&x,&y),&z);
printf("%d,%d,%d\n",x,y,z);
}*/
#include<stdio.h>
#include<string.h>
#include<conio.h>
void fun(char s[],char t[])
{
int i,d;
d=strlen(s);
for(i=0;i<d;i++)
t[i]=s[d-1-i];
for(i=0;i<d;i++)
t[d+i]=s[i];
t[2*d]='\0';
}
main()
{
char s[100],t[100];
printf("\nPlease enter string S:");
scanf("%s",s);
fun(s,t);
printf("\nThe result is:%s\n",t);
}
0 0
原创粉丝点击