麻烦大家了
有急用
谢谢!!
1、main()
{ int a[]={ 2,4,6}, *prt=&a[0], x=8,y,z;
for(y=0; y<3; y++)
z=(*(prt+y)<x)? *(ptr+y):x;
printf("%d\n", z);}
2、#define PR(ar) printf("%d", ar)
main()
{ int j, a[]={ 1,3,5,7,9,11,13,15}, *p=a+5;
for(j=3; j; j--)
{ switch(j)
{ case 1:
case 2: PR(*p++); break;
case 3: PR(*(--p));}
}
}
3、main()
{ char b[]="ABCDEFG";
char *chp=&b[7];
while(--chp>&b[0]) putchar(*chp);
putchar('\n'); }
4、int ast(int x,int y,int * cp,int * dp)
{ *cp=x+y; *dp=x-y; }
main()
{ int a,b,c,d;
a=4;b=3;
ast(a,b,&c,&d);
printf("%d %d/n",c,d); }
5、#include "string.h"
#include "stdio.h"
strle(char a[],char b[])
{ int num=0,n=0;
while(*(a+num)!='\0') num++;
while(b[n]){ *(a+num)=b[n];num++;n++;}
return (num);}
main()
{ char str1[81],str2[81],*p1=str1,*p2=str2;
gets(p1); gets(p2);
printf("%d\n",strle(p1,p2)); }
运行上面程序,如果从键盘上输入字符串qwerty和字符串abcd
6、fun(int n,int *s)
{ int f1,f2;
if(n = =1||n = =2) *s=1;
else { fun(n-1,&f1); fun(n-2,&f2); *s=f1+f2;} }
main()
{ int x;
fun(6,&x); printf("%d\n",x); }
7、#include<string.h>
fun(char *w,int n)
{char t,*s1,*s2;
s1=w;s2=w+n-1;
while(s1<s2)
{t=*s1++;*s1=*s2--;*s2=t;}
}
main()
{char *p;p="1234567";
fun(p,strlen(p);puts(p);
}
8、#include<stdio.h>
main()
{int a[10]={1,2,3,4,5,6,7,8,9,0},*p;
p=a;
printf("%x\n",p);
printf("%x\n",p+9);
}
已知第一个printf输出的结果是194,请给出第二个printf的输出结果。
9、#include<stdio.h>
fun(int *s,int n1,int n2)
{ int i,j;
i=n1;j=n2;
while(i<j)
{*(s+i)+=*(s+j);
*(s+j)+=*(s+i);
i++;j--;
}
}
main()
{int a[6]={1,2,3,4,5,6},i,*p=a;
fun (p,0,3);
fun(p,1,4);
fun(p,3,5);
for(i=0;i<6;i++)
printf("%d",*(a+i));
printf("\n");
}
10、main()
{char a[]="ABCDEFG", k, *p;
fun(a, 0, 2); fun(a, 4, 6);
printf("%s\n", a);
}
fun(char *s, int p1, int p2)
{char c;
while(p1<p2)
{c=s[p1]; s[p1]=s[p2];
s[p2]=c; p1++; p2--;}
}
因为有急用
小女子先在这里谢谢大家了
麻烦各位了...