練習6-1
#include int min2(int a, int b)
int main(void)
練習6-2
#include int min3(int a, int b, int c)
int main(void)
練習6-3
#include int cube(int x)
int main(void)
練習6-4
#include int sqr(int x)
int pow4(int x)
int main(void)
練習6-5
#include int sumup(int n)
return sum;
}int main(void)
練習6-6
#include void alert(int n)
return;
}int main(void)
練習6-7
#include void hello(void)
int main(void)
練習6-8
#include int min_of(const int v, int n)
return min;
}int main(void)
; min = min_of(v,4);
printf("min = %d\n",min);
return 0;
}
練習6-9
#include #define num 4
void rev_intary(int v, int n)
return;
}int main(void)
; rev_intary(v,num);
for (i = 0; i < num; i++)
return 0;
}
練習6-10
#include #define num 4
void intary_rcpy(int v1,const int v2,int n)
return;
}int main(void)
; int v1[num];
intary_rcpy(v1,v2,num);
for (i = 0; i < num; i++)
return 0;
}
練習6-11
#include int search_idx(const int v,int idx,int key,int n)
} return j;
}int main(void)
; int key = 7;
int idx[7] = ;
num = search_idx(v,idx,key,7);
printf("和key相等的元素的個數為%d。\n",num);
for (i = 0; i < 7; i++)
return 0;
}
練習6-12
#include void mat_mul(const int a[4][3],const int b[3][4],int c[3][3])
} return;
}int main(void)
, , , };
int b[3][4] = ,, };
int c[3][3] = ;
mat_mul(a,b,c);
printf("a = \n");
for (i = 0; i < 4; i++)
printf("\n");
} printf("b = \n");
for (i = 0; i < 3; i++)
printf("\n");
} printf("c = b * a = \n");
for (i = 0; i < 3; i++)
printf("\n");
} return 0;
}
練習6-13
#include void mat_add(const int a[4][3], const int b[4][3], int c[4][3]) }}
void mat_print(const int m[4][3])
printf("\n");
} putchar('\n');
}int main(void)
,,, } ,
,,, } };
int sum[4][3]; /* 總分 */
mat_add(tensu[0], tensu[1], sum); /* 求兩次考試中成績的總和 */
puts("第一次考試的分數"); mat_print(tensu[0]); /* 顯示第一次考試的分數 */
puts("第二次考試的分數"); mat_print(tensu[1]); /* 顯示第二次考試的分數 */
puts("總分"); mat_print(sum); /* 顯示總分 */
return 0;
}
練習6-14
#include int main(void)
return 0;
}
練習6-15
#include static int n;
void put_count(void)
int main(void)
明解C語言(入門篇)第六章
練習6 1 include intmin2 int a,int b return min int main void 練習6 2 include intmin2 int a,int b,int c if creturn min int main void 練習6 3 include intcube ...
明解C語言入門篇(第12章練習題)
include define name len 64 struct student int main void printf 姓名 s n takao.name printf 身高 d n takao.height printf 體重 1f n takao.weight printf 獎學金 ld ...
明解C語言 入門篇 第七章練習題
include intmain include include intmain include unsigned rrotate unsigned x,int n unsigned lrotate unsigned x,int n intmain printf 輸入錯誤!請重新輸入!n if a 1...