C Language Blog Job--function nested call

Source: Internet
Author: User
Tags new set

C Language Blog Job--function nesting call one, the experiment Work 1.1 PTA topic decimal conversion binary design Ideas
传入n边界条件:n<=1递归模式:n/2每一轮的递归都输出n取余2
Code

Debugging issues

Boundary value set to N==1, resulting in segment error
Workaround: Instead of n<=1, you can avoid

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

1.2.2 Display your engineering documents, such as:

1.2.3 function code Part of this system code total number of lines: 386
    • Header file

    • Insert student information and student performance information code

    • Delete Student Score Info code

    • Overall sorting code

1.2.4 Debug Results Display menu and function implementation
    • menu and Function 1 (number of new students)

    • Function 4 (Show all score information) Show function 1 operation result

    • Function 2 (revision result)

    • Function 3 (delete scores)

    • Feature 5 (two sort) new set of data

    • Function 6 (Inquiry information)

    • Function 7 (exit System)

Robustness
    • Illegal importation of orders and school numbers

    • The number of students crossed out (up to 50, adjustable), the number of courses crossed (up to 10, adjustable), student number, telephone illegal input, number repetition

    • No results from query

1.2.5 debugging encountered problems and solutions.
    • New data will be overwritten when the number of new people has been entered
      WORKAROUND: Define global variables, all functions are shared, no data is entered when +1, new data is written on this array of global variables.

    • The problem of calculating the total score and the average
      Just beginning to think that the new data and modify the data are used to calculate the total score and average points, so I intend to write the calculation process as a function for them to call, and later found that the new and modified calculations are not the same, can not use a single code. There is also the calculation of the average tick, if the denominator is 0, the result will be wrong.
      Workaround: The function count only retains the code when the input is evaluated, and the code that is evaluated after the modification and deletion is directly appended to the respective function. The denominator of 0 is a condition of judgement, when the denominator is 0 o'clock, the average is directly equal to 0

    • Problems with debugging robustness
      The robustness of the input command, starting with%d absorption, but the input letters or other characters will be an error, use%c absorption, in case there are extra characters can not absorb
      Solution:%c absorption, absorption of the Addend group, and use of get, absorb thoroughly, in the judgment array to absorb excess data (for insurance, define the array to give the empty string first), and the correctness of%c.

(There are many problems, but too much too miscellaneous, can not be recorded and listed, of course, there are also some potential problems after the program has not been found)

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

Third, read the code
    • Topic
    • Code
#include<stdio.h>int N;int s[31]; // 存放划分结果 int top = -1; // 数组指针 int count = 0; // 统计输出的次数 int sum = 0; // 拆分项累加和 void division (int i);int main (){    scanf ("%d", &N);        division (1);        return 0; }void division (int i) {    if (sum == N) {        count ++;        printf("%d=", N);        int k;        for (k=0; k<top; k++) {            printf("%d+", s[k]);        }        if (count%4 == 0 || s[top] == N) {            printf("%d\n", s[top]);        } else {            printf("%d;", s[top]);        }        return;    } // 输出部分     if (sum > N) {        return;    }    for (int j=i; j<=N; j++) {        s[++top] = j;        sum += j;         division (j);        sum -= j;        top --;    } // 算法主体 }

Change the code with a depth-first thought, simply said, is not to break down the original number, but from the bottom of the beginning to gather, until it is just equal to a given number, this method of thinking is worth learning, sometimes from the positive to decompose may be difficult, this is can try to reverse consideration. The continuous definition of global variables in the code also gives me a little bit of a chance of thinking about it.

Iv. Study Summary of the Week 1. Summarize what you learned this week.

1. Macro definition: Simple substitution with no parentheses
Format: #define Macro name string
Purpose: Define constants; macros with parameters to implement functions of some simple functions

2. The file contains
Format: #include < file name > or # include "file name"
Difference: #include < file name > will only be found in the system folder, not for their own files, #include "file name" first to the current working folder to find, and then to the System folder lookup, generally used for their own writing of the header file.

3. Compilation preprocessing
By precompiling The build program, you can increase efficiency by starting with #, common preprocessor directives such as # include, #define, #if #else ... #endif等

4. Large program composition
Contains the main function file, header file, and other function files, belong to different modules, through the exchange of modules to achieve large-scale functions.
Inter-module Communication considerations:

    • In addition to the header file itself, all other files are added with the header file.
    • Inside the header file, include all function prototype definitions and system header files, such as standard input and output.
    • When other modules refer to the global variables of the main function, add the extern variable name, which indicates that it is an external variable.

5. Pointer Advanced
Set two-dimensional array a "2" "3"

    • Column pointers: int *p;p=a;
      * (P+i) represents the element from position I of a "0" "0"

    • Row pointers: Int (*p) "n"; p=a;
      P+i represents a "I"; a "I" "J" =* (* (p+i) +j) = (* (p+i)) "J" =p "I" "J"

    • Array of pointers: int *p "n"; int**p;p=pp;
      P "I" is a pointer

2. List some of the wrong questions this week.


Analysis: *p[3] is actually defined as a level two pointer, and A[3] defines a first level pointer, so a option different level pointers can not be assigned a value, b option *p is a primary pointer, a[0] is an element can not be assigned a value, C option p is a level two pointer, &a[0] is a level pointer cannot be assigned, so D is correct.


Analysis: A member must be a pointer to a struct, and only b meets the criteria.

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.