随笔分类 - c/c++
摘要:c语言中自定义函数计算x的n次方。 1、直接输出形式 #include <stdio.h> int main(void) { int i, x, n; int tmp = 1; puts("please input the values of x and n."); printf("x = ");
阅读全文
摘要:c语言中while语句控制程序循环的次数 1、 #include <stdio.h> int main(void) { int i; puts("please input an integer."); printf("i = "); scanf("%d", &i); while(i-- > 0) {
阅读全文
摘要:函数定义: 函数调用: 函数定义:函数头和函数体。 函数头:包括返回值类型、函数名和形参声明 函数体:复合语句,仅在摸个函数中使用的变量,原则上应在该函数中声明和使用,但要注意不能声明和形参同名的变量,否则会发生变量名冲突的错误。 #include <stdio.h> int max2(int a,
阅读全文
摘要:1、 #include <stdio.h> #define NUMBER 1000 int main(void) { int i, j, num, a[NUMBER], max, b[11] = {0}; do { printf("num = "); scanf("%d", &num); if(nu
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, k, a[2][4][3], b[4][3] = {0}; puts("please input the elements of the array."); for(i = 0; i < 2; i++)
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, a[6][2], b[2] = {0}, c[6] = {0}; puts("please input the elements of array a."); for(i = 0; i < 6; i++
阅读全文
摘要:c语言中实现矩阵的转置 1、 #include <stdio.h> int main(void) { int i, j, a[4][6], b[6][4]; puts("please input the elements of matrix a."); for(i = 0; i < 4; i++)
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, a[6][2]; puts("please input the elements of the array."); for(i = 0; i < 6; i++) { for(j = 0; j < 2;
阅读全文
摘要:c语言中计算矩阵的乘积。 矩阵相乘的条件:左侧矩阵的列数等于右侧矩阵的行数。 矩阵相乘的结果:行数为左侧矩阵的行数,列数为右侧矩阵的列数。 #include <stdio.h> int main(void) { int i, j, k, a[4][6], b[6][7], c[4][7] = {0}
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, k, a[2][4][3], b[4][3] = {}; for(i = 0; i < 2; i++) { for(j = 0; j < 4; j++) { for(k = 0; k < 3; k++)
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, a[8][3] = {}; puts("please input the scores of the students."); for(i = 0; i < 6; i++) { for(j = 0; j
阅读全文
摘要:求3行4列矩阵和4行5列矩阵的乘积。 1、 #include <stdio.h> int main(void) { int i, j, k, a[3][4], b[4][5], c[3][5] = {0}; puts("please input the elements of matrix a.")
阅读全文
摘要:1、 #include <stdio.h> int main(void) { int i, j, a[6][2]; for(i = 0; i < 6; i++) { for(j = 0; j < 2; j++) { printf("a[%d][%d] = ", i, j); scanf("%d",
阅读全文
摘要:求4行3列矩阵和3行4列矩阵的乘积。各构成元素的值从键盘输入。 1、 #include <stdio.h> int main(void) { int i, j, k, a[4][3], b[3][4], c[4][4] = {0}; puts("input the elements of 4 row
阅读全文
摘要:1、 #include <stdio.h> #define NUMBER 1000 int main(void) { int i, j, num, a[NUMBER], b[11] = {0}; do { printf("num = "); scanf("%d", &num); if(num < 1
阅读全文
摘要:1、 #include <stdio.h> #define NUMBER 1000 int main(void) { int i, j, num, a[NUMBER], b[11] = {0}; do { printf("num = "); scanf("%d", &num); if(num < 1
阅读全文
摘要:1、 #include <stdio.h> #define NUMBER 1000 int main(void) { int i, num, a[NUMBER]; do { printf("number of element: "); scanf("%d", &num); if(num < 1 |
阅读全文
摘要:1、 #include <stdio.h> #define NUMBER 4 int main(void) { int i, a[NUMBER]; printf("the number of elements: %d\n", NUMBER); for(i = 0; i < NUMBER; i++)
阅读全文
摘要:在应用对象式宏的数组中对数组的元素进行倒序排列。 1、 #include <stdio.h> #define NUMBER 9 int main(void) { int i, a[NUMBER]; puts("please input the elements."); for(i = 0; i <
阅读全文
摘要:将数组a的元素倒序复制到数组b中。 1、 #include <stdio.h> int main(void) { int i, a[7] = {3,2,8,4,2,9,1}, b[7]; for(i = 0; i < 7; i++) { b[i] = a[6 - i]; } for(i = 0; i
阅读全文

浙公网安备 33010602011771号