摘要: random module三个常用function: randint, choice, shuffle import random print(random.randint(1,10)) #从1到10(两头都包含)中随机选择一个数 words = ['grable', 'craven', 'mave 阅读全文
posted @ 2020-05-04 20:59 profesor 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 输入一个正整数n(1<=n<=6),根据下式生成n阶方阵,将该方阵转置(行列互换)后输出。 a[i][j] = i*n+j+1 #include <stdio.h> int main() { int n; printf("输入方阵维数: \n"); scanf("%d", &n); int a[n] 阅读全文
posted @ 2020-05-04 17:36 profesor 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 要求: 输入2个正整数m和n(1<=m<=6, 1<=n<=6),然后输入矩阵a(m行n列)中的元素,分别求出各行元素之和,并输出。试编写相应程序 #include <stdio.h> int main() { int m, n; // m,n作为行、列数 scanf("%d", &m); scan 阅读全文
posted @ 2020-05-04 16:39 profesor 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 输入两数a,b,交换值后输出 #include <stdio.h> void swap(int *pa, int *pb) { int t; t = *pa; *pa = *pb; *pb = t; } int main() { int a, b; printf("input two numbers 阅读全文
posted @ 2020-05-04 08:59 profesor 阅读(147) 评论(0) 推荐(0) 编辑