C Language Blog Job--function nested call

Source: Internet
Author: User
Tags array length

First, the experimental work 1.1 PTA title: Recursive method for any 10 of data in descending order design ideas
//将选择排序法进行变形if(n为1)//递归出口返回else{index=10-n;//index从0开始for(i=10-n+1 to 9)if(a[i]小于a[index])交换交换a[index]和a[10-n]sort(a,n-1);//递归式子}
Code

Debugging issues

The value of index is tried many times before the rule is summed up.

1.2 Student performance Management System 1.2.1 Drawing function module diagram, briefly introduces function function.

1.2.2 Show your project documents

1.2.3 function Code section (requires your header file, insert student information and student performance Information code, delete student score information code, total score sort code. Be sure to include the necessary comments in the code. )
  • Total lines of code: 318
  • Header file
  • Insert student information and student performance information code

  • Delete Student Score Info code
  • Sorting codes for total and average points

    1.2.4 Debug Results display (required to display the menu, each command run results, the illegal data must have a test and prompt, such as the user number input illegal, or enter the repetition number, the prompt insertion failure. Query not to the corresponding student information to give tips and so on. )
  • Enter student Scores

  • Add Student Scores
  • Revise student grades


  • Delete Student Scores

  • Display information
  • Query information

    1.2.5 debugging encountered problems and solutions.

    At first, all the other function files are precompiled into the main file, the program has not been running.
    In the Student.h header file, the function is not declared.

    Second, this week's topic set PTA Final ranking.

    Third, read the code (find a good code map display, first describe the topic, and then paste the code, you can add comments in it.) Describe what the code is capable of and what are the advantages? The code requires recursive correlation code for this time. )

    A recursive algorithm for finding the existence of data element x in ordered array a

    #include <stdio.h>int BSearch(int a[],int x,int low,int high);void main(void){int a[] = {1,3,4,5,17,18,31,33};int x = 17;int bn;bn = BSearch(a,x,0,7);if(bn == -1) printf("x=%d,不在数组a中",x);else    printf("x=%d,在数组a中下标为%d",x,bn);printf("\n");}int BSearch(int a[],int x,int low,int high){int mid;if(low > high) return -1;   //查找不成功mid = (low + high) / 2;if(x == a[mid]) return mid; //查找成功else if(x < a[mid]){    return BSearch(a,x,low,mid - 1);}else{    return BSearch(a,x,mid + 1,high);}}

    The parameters of the algorithm include: Ordered array A, the data element x to be found, subscript low in the lower bounds of the array, and the upper bounds subscript high. When a data element x is found in array A, the function returns the subscript of array A, and when the data element x is not found in array A, the function returns-1.

    Iv. Summary of the study this Week 1. Introduce this week's learning content
  • 1.1 Macro definition (macro substitution)
    1. Format: #define Macro name Macro definition string
    2. Use
    1. Symbolic constants
    2. Simple function function implementation
  • 1.2 file inclusion (include)
    1. Function: Insert the contents of the specified file template into the location of # include
    2. Format: #include < > or # include ""
    3. File name:. h or. c
  • 1.3 Program File Module
    When a C language program consists of multiple file modules, the entire program allows only one main () function, and the program runs starting from the main () function.
  • 1.4 External variables and static global variables
    1. External variable format: extern variable table name;
    2. Adding static to the global variable before it becomes a global variable is scoped to the current file template.
  • 1.4 Pointer Array
    1. Format: type name * array name [array length];
    2. Function: In the operation, both the array elements can be directly assigned and referenced, you can also indirectly access the elements point to the contents of the cell.
  • 1.5 Level Two Hands
    1. Definition: type name * * variable name;
    2. For example:

    int a;int *p=&a;*p=a;int **pp=&p;*pp=p;**pp=a;
    3. Pointer form for two-D arrays
    Level Two: A+i
    First level: A[i]+j (a+i) +j
    element: A[i][j]
    (* (a+i) +j)
  • 1.6 Dynamic input of multiple strings
    Application Space: = (type name *) malloc ()
    Freeing space: Free ()
  • 1.7 Pointers to functions
    1. Definition Format: type name ( variable name) (parameter table);
    2. Call Format: (
    variable name) (parameter table);

    2. Learning experience.

    This week learned a lot of new things, which answered some of the previous code did not understand the doubts, but like a two-level pointer, pointer array to grasp proficiency, not easy, it takes time to practice. Linked list is to see a long time also did not understand a little. For this week's student management system, the completion of the process is very difficult, not understanding of the project, how to set up the head file, and so on, just started playing two functions, the program does not work up, very uncomfortable, a little change, or to the contents of each piece to understand, do not confuse the line.

C Language Blog Job-function nested call

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.