91学习

陪伴你每一天!

将输入的数据从大到小排列

#include <stdio.h>void swap(int *p1,int *p2){ int temp; temp=*p1; *p1=*p2; *p2=temp;}void exchange(int *pt1,int *pt2,int *pt3){ if(*pt1<*pt2) swap(pt1,pt2); if(*pt1<*pt3) swap(pt1,pt3); if(*pt2<*pt3) swap(pt2,pt3);}void main(){ int

变量是形式参数交换两个变量的值

#include <stdio.h>void swap(int a,int b){ int tmp; tmp=a; a=b; b=tmp;}void main(){ int x,y; printf("请输入两个数:\n"); scanf("%d",&x); scanf("%d",&y); swap(x,y); printf("x=%d\n",x); printf("y=%d\n&

指针变量做参数交换两个变量值

#include <stdio.h>void swap(int *a,int *b){ int tmp; tmp=*a; *a=*b; *b=tmp;}void main(){ int x,y; int *p_x,*p_y; printf("请输入两个数:\n"); scanf("%d",&x); scanf("%d",&y); p_x=&x; p_y=&y; swap(p_x,p_y); p

用指向指针的指针输出金属元素

#include <stdio.h>int main(){ int i; char **p; char *element[]={ "锂", "铍", "钠", "镁", "铝", "钾", "钙" }; for(i=0;i<7;i++) { p=element+i; printf("%s\n",*p);

输出12个月

#include <stdio.h>void main(){ int i; char *month[]={ "January", "February", "March", "April", "May", "June", "July", "August", "September", &qu

利用指针实现字符串的复制

#include <stdio.h>void main(){ char str1[]="you are beautiful",str2[30],*p1,*p2; p1=str1; p2=str2; while(*p1!='\0'){ *p2=*p1; *p1++; *p2++; } *p2='\0'; printf("now the str2 is:\n"); puts(str2);}

字符串与指针

#include <stdio.h>int main(){ char *string="hello"; printf("%s",string); printf("\n"); return 0;}

对于一个3行3列数组输出第二行

#include <stdio.h>int main(){ int a[3][3],i,j; printf("please intput :\n"); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%d",*(a+i)+j); printf("the second line is:\n"); for(j=0;j<3;j++) printf("%5d

输出二维数组的第三行

#include <stdio.h>int main(){ int a[3][5],i,j,(*p)[5]; p=&a[0]; printf("please input number:\n"); for(i=0;i<3;i++) for(j=0;j<5;j++) scanf("%d",(*(p+i)+j));         p=&a[2]; printf(

二维数组与指针

#include <stdio.h>int main(){ int a[3][5],i,j; printf("please input the array:\n"); for(i=0;i<3;i++){ for(j=0;j<5;j++){ scanf("%d",a[i]+j); } } printf("the arrray is:\n"); for(i=0;i<3;i++){ for(j=0;j&