华科周纯杰版c语言答案 联系客服

发布时间 : 星期一 文章华科周纯杰版c语言答案更新完毕开始阅读f651c36a561252d380eb6ebd

int a,b,c;

int *pa=&a,*pb=&b,*pc=&c;

clrscr();

printf(\ 3 integers :\\n\\n\ scanf(\ scanf(\ scanf(\ if (b>c)

swap(pb,pc); if (a>b)

swap(pa,pb); if (b>c) swap(pb,pc);

printf(\ printf(\ }

void swap(int *p1, int *p2) {

int temp; temp=*p1; *p1=*p2; *p2=temp; }

3有一字符串,包含n个字符。使用指针,将此字符串从第m个字符开始的全 部字符复制成为另一个字符串。 # include # include # include # define N1 20 # define N2 20 void main() { char str1[N1],str2[N2]; int m,n,i,j; clrscr(); printf(\ gets(str1);

n=strlen(str1); do { printf(\ scanf(\ }while(n

4 输入一个字符串,内有数字和非数字字符,如:a123x456 17960?302tab5876 将其中连续的数字作为一个整数,依次存放到一数组a中。例如123放在a[0] 中,456放在a[1]中……统计共有多少个整数,并输出这些数。 # include # include # include # include void main() { char str[60],ch; int i,j,bit,dit,n; long int a[20]; clrscr(); printf(\ scanf(\ for (i=0,j=0,a[0]=0,bit=1,dit=0;i

if(isdigit(ch=*(str+i))) { dit=1; a[j]*=bit; a[j]+=(ch-48);

bit=10; n=j; } else { if (dit==1) {

j++; a[j]=0 ; } dit=0; bit=1; } }

printf (\ for (i=0;i<=n;i++)

printf(\ }

5 利用数组和指针,将一个4*4的矩阵转置,并输出矩阵中的最大值及其位置 # include # include # define N 4 void initpm(float * pm[], float mt[][N]); void main() { void inputm(float mt[][N]); void printm( float mt[][N]); void schmax(float mt[][N]); void tranmtx(float mt[][N]);

float mtx[N][N] ; clrscr(); inputm(mtx); printf(\ printm(mtx); schmax(mtx); tranmtx(mtx); printm(mtx); printf(\ }

void inputm(float mt[][N]) { int i,j;

float *pm[N]; initpm(pm,mt);

printf(\ for(i=0;i<4;i++)

for (j=0;j<4;j++,pm[i]++) scanf(\ }

void printm( float mt[][N]) { int i,j;

float *pm[N]; initpm(pm,mt); for(i=0;i

for(j=0;j

void schmax(float mt[][N]) {

int i,j,line ,colum; float *pm[N],max; initpm(pm,mt); max=mt[0][0]; line=0; colum=0;

for (i=0;i

if (max<*(pm[i]+j)) { max=*(pm[i]+j); line=i; colum=j; } }

printf(\