Experiment6

Posted ohtcjlo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Experiment6相关的知识,希望对你有一定的参考价值。

task4

#include <stdio.h>
#include<string.h>
#define  N 100

typedef  struct  
    char num[10];       
    int s1;             
    int s2;             
    double sum;         
    char level[10];     
 STU;


int fun(STU a[], int n, STU h[]);

int main() 
   STU s[N]= "GA05", 85, 76, 
              "GA03", 76, 90, 
              "GA02", 69, 90, 
              "GA04", 85, 56, 
              "GA01", 91, 95,
              "GA07", 72, 80, 
              "GA08", 64, 45, 
              "GA06", 87, 98, 
              "GA015", 85, 86, 
              "GA013", 91, 97 ; 
    STU h[N];                          
    int i, k, n = 10; 


    k = fun(s, n, h);

    printf("There are :\\n");
    for(i = 0; i < k; i++)
        printf("%s %d %d %.2f %s\\n", h[i].num, h[i].s1, h[i].s2, h[i].sum, h[i].level);
    
    return 0;



int fun (STU a[], int n, STU h[]) 
    int i,j=0;
    double sum=0;
    double s=0;
    for (i=0;i<n;i++)
        a[i].sum=a[i].s1*0.7+a[i].s2*0.3;
        s+=a[i].sum;
    
    s=s/n;
    for (i=0;i<n;i++)
        if (a[i].s1*0.7+a[i].s2*0.3>=s)
        strcpy(a[i].level,"均分以上");
        h[j++]=a[i];
        
    
    
    
    return j;

task5

#include <stdio.h>
#include <string.h>
#define N 5

typedef struct student 
    char name[10];
    int num;
    int maths;
    int computer;
    int english;
    int sum;
    char level[10];
 STU;

void fun(STU a[], int n);

int main() 
    STU s[6*N]= "A001", 1, 34, 67, 80,
                 "B003", 3, 78, 87, 90,
                 "A002", 2, 90, 98, 99,
                 "B002", 4, 56, 78, 98,
                 "A005", 5, 35, 67, 79 ;
    int i;

    fun(s, N);
    for(i = 0; i < N; i++)
      printf("%s %d %d %d %d %d %s\\n", s[i].name, s[i].num, s[i].maths, s[i].computer, s[i].english, s[i].sum, s[i].level);
    
    return 0;



void fun(STU a[], int n) 
   int i=0;
    int  max=0,min=300,s=0;
    for (i=0;i<n;i++)
        a[i].sum=a[i].maths+a[i].computer+a[i].english;
        if (a[i].sum>max) max=a[i].sum;
        if (a[i].sum<min) min=a[i].sum;
    
    
    for (i=0;i<n;i++)
        if (a[i].sum==max) strcpy(a[i].level,"优秀");
        else if (a[i].sum==min) strcpy(a[i].level,"不合格");
        else  strcpy(a[i].level,"合格");
    

task6

#include <stdio.h>
#define N 5

typedef struct student 
    long no;
    char name[20];
    int score;
 STU;


void input(STU s[], int n);
int find_min_list(STU s[], STU t[], int n);
void output(STU s[], int n);

int main() 
    STU stu[N], min_list[N];
    int count;

    printf("录入%d个学生信息\\n", N);
    input(stu, N);

    printf("\\n统计最低分人数和学生信息...\\n");
    count = find_min_list(stu, min_list, N);

    printf("\\n一共有%d个最低分,信息如下:\\n", count);
    output(min_list, count);

    return 0;



void input(STU s[], int n) 
    int i=0;
    for (i=0;i<n;i++)
        scanf("%ld %s %d", &s[i].no,&s[i].name,&s[i].score);



void output(STU s[], int n) 
    int i=0;
    for (i=0;i<n;i++)
        printf("%ld %s %d\\n", s[i].no,s[i].name,s[i].score);



int find_min_list(STU s[], STU t[], int n) 
    int i=0;
    int j=0;
    int  min=s[0].score;
    for (i=0;i<n;i++)
        if (s[i].score<min) min=s[i].score; 
    for (i=0;i<n;i++)
        if (s[i].score==min) t[j++]=s[i];
    
    return j;

 

20162314 Experiment 4 - Graph

Experiment report of Besti

course:《Program Design & Data Structures》

Class: 1623

Student Name: Wang, Yixiao

Student Number:20162314

Tutor:Mr.Lou、Mr.Wang

Experiment date:2017.11.19

Secret level: Unsecretive

Experiment time:60 minutes

Major/Elective:Major

Experiment order:4

Experiment content

  1. Graph implement and apply-1
  1. Graph implement and apply-2

3.Graph implement and apply-3

Experiment situation

Exp1 Graph implement and apply-1

  • It\'s easy to finish this experiment.
  • To start with , import to form a new LinkedBinaryTree to start the experiment.
  • Next , use the method GetRight GetLeft to ealuation.
  • Then , new element "ABC".
  • Last , Assert.assertequals();

Exp2 Graph implement and apply-2

  • To start with , use the number to replace "A B C D ....."
  • Next , new newNode
  • Then, creat BinTree to get left child and right child
  • Use three methods preOrderTraverse,inOrderTraverse,postOrderTraverse.

Exp3 Graph implement and apply-3

  • To start with , creat a class TwentyQuestionsPlayer
  • String the Questions and the answers as the order
  • New them
  • Write a method play(),Yes =Y , No=N .
  • Next , write a function to finish this experiment.

Code hosting

PSP5.1(Personal Software Process)

Steps Time percent
requirement 45minutes 16.7%
design 50minutes 18.5%
coding 1.5hours 32.2%
test 30minutes 11.1%
summary 55minutes 19.2%

以上是关于Experiment6的主要内容,如果未能解决你的问题,请参考以下文章