猜词游戏 猜词游戏import randomwords = ['chicken', 'dog', 'cat', 'mouse', 'frog']guessTimes = 14guessLetters = ""def pickWord(): return random.choice(words)def play(): word = pickWord() while True: guess = getGuess(word) if proces
插入排序(汇编代码) 插入排序(汇编代码)include irvine32.inc.dataarr dd 78, 95, -45, 21, 0, -63, 100, -56, 25count dd lengthof arr.codemain proc call InSertSort call output exitmain endpInSertSort procmov edi, 1start: cmp edi, countjae homemov esi, 0begin: cmp esi, e
冒泡排序(汇编代码) 冒泡排序(汇编代码)include irvine32.inc .data count dd lengthof arr ;lengthof arr == ($-arr)/4 arr dd 78, 25, -56, 0, 49, 32, 100, 6542, 231.codemain proc mov eax, count mov esi, 0 ;call dumpregs again_1: cmp esi, count jae final call B
选择排序(汇编代码): 选择排序(汇编代码):include irvine32.inc.data arr dd 78, -67, 32, 90, -87, 45, 24, 0, 4 count dd ($-arr)/4 .codemain proc call SelectSort call output exitmain endpSelectSort proc mov esi, 0 again: cmp esi, count jae final call i
6-6 求单链表结点的阶乘和 (15分) 6-6 求单链表结点的阶乘和 (15分)本题要求实现一个函数,求单链表L结点的阶乘和。这里默认所有结点的值非负,且题目保证结果在int范围内。函数接口定义:int FactorialSum( List L );其中单链表List的定义如下:typedef struct Node *PtrToNode;struct Node { int Data; /* 存储结点数据 */ PtrToNode Next; /* 指向下一个结点的指针 */};typedef PtrToNode
6-7 统计某类完全平方数 (20分) 6-7 统计某类完全平方数 (20分)本题要求实现一个函数,判断任一给定整数N是否满足条件:它是完全平方数,又至少有两位数字相同,如144、676等。函数接口定义:int IsTheNumber ( const int N );其中N是用户传入的参数。如果N满足条件,则该函数必须返回1,否则返回0。裁判测试程序样例:#include <stdio.h>#include <math.h>int IsTheNumber ( const int N );int mai
基础实验3-2.1 一元多项式求导 (20分) 基础实验3-2.1 一元多项式求导 (20分)设计函数求一元多项式的导数。输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。输入样例:3 4 -5 2 6 1 -2 0输出样例:12 3 -10 1 6 0#include <stdio.h>int main(){ int x, y, flag = 0;
加权无向图的邻接表存储形式 加权无向图的邻接表存储形式#include <stdio.h>#include <stdlib.h>#define MAX 10typedef struct Node { char data; int sum; struct Node* next;}*GNode;typedef struct Vertex { char c; GNode first;}*GVertex;typedef struct Graph { int n; int e; st
加权有向图的邻接矩阵存储形式 加权有向图的邻接矩阵存储形式#include <stdio.h>#include <stdlib.h>#define MAX 10#define NoEdge 9999999typedef struct Vertex { char c;}* GVertex;typedef struct Graph { int n; int e; struct Vertex vertex[MAX]; int edges[MAX][MAX];}* MGraph;void
6-12 二叉搜索树的操作集 (30分) 6-12 二叉搜索树的操作集 (30分)本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST );Position FindMax( BinTree BST );其
根据先序遍历和中序遍历输出后序遍历 根据先序遍历和中序遍历输出后序遍历#include <stdio.h>#include <stdlib.h>char Pre[100], In[100];typedef struct Node {char Data;struct Node* Left;struct Node* Right;}*Tree;Tree BuildTree(char* Pre, char* In, int n);void PostOrder(Tree T);int main(){Tr
根据后序遍历和中序遍历输出先序遍历 根据后序遍历和中序遍历输出前序遍历#include <stdio.h>#include <stdlib.h>char Post[100], In[100];typedef struct Node { char Data; struct Node* Left; struct Node* Right;}* Tree;Tree BuildTree(char* Post, char* In, int n);void PreOrder(Tree T);int ma
插入排序算法 插入排序算法#include <stdio.h>int a[100000];int main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { int temp = a[i]; for (int j = 0; j < i; j++) { if (
练习7.1 排序 (25分) 练习7.1 排序 (25分)给定N个(长整型范围内的)整数,要求输出从小到大排序后的结果。本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下:数据1:只有1个元素;数据2:11个不相同的整数,测试基本正确性;数据3:103个随机整数;数据4:104个随机整数;数据5:105个随机整数;数据6:105个顺序整数;数据7:105个逆序整数;数据8:105个基本有序的整数;数据9:105个随机正整数,每个数字不超过1000。输入格式:输入第一行给出正整数N(≤10
选择排序算法 选择排序算法#include <stdio.h>int a[100000];int main(){ int n, position = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { int max = -999999, temp; for (int j = 0; j &l
冒泡排序算法 冒泡排序#include <stdio.h>int a[100000];int main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1 - i; j++) { int temp; if (