C Language Blog Job-data type

Source: Internet
Author: User
Tags array length

First, the PTA experimental work Title 1: Inverted number string 1. PTA Submission List
2. Design Ideas
    • 1. Define I,J for Loop
    • 2. Enter n
    • 3.for (i=1;i<=n;i++), let the numeric order from small to large behind with a blank order output, if I equals N, then no space output
    • 4.for (j=n-1;j>=1;j--), starting with the maximum number (excluding the maximum number), preceded by a space output
3. Code
4. Problems encountered in commissioning process and PTA submission List status note
    • Format error: Output maximum number 6 o'clock is still with a space after the maximum number after the reverse of the front with a space output conflict
    • WORKAROUND: Special case i=n, the maximum number of outputs without any spaces

Topic 2. Send red envelopes 1. PTA Submission List
    • 2. Design Ideas

    • Idea: Solving the problem with a global variable definition function
    • 1. Declare the function void Money (int m), define integer global variable A to hold the amount remaining after deducting the corresponding denomination, m to deposit the remaining amount,
      N Deposit notes denomination, F deposit Total Amount
    • 2. Define the function, using the integer variable B to hold the number of the corresponding banknotes, first a=m%n; Re-operation b=m/n; Finally M=a;
    • 3.M initially let it be equal to the F total amount, and then use the function, because M is a global variable, so the last function ends, its value can continue to be used for the next function
    • 4.money (100);
      Money (50);
      Money (20);
      Money (10);
      Money (5);
      Money (2);
      Money (1);
    • 5.printf ("%3d yuan:%3d zhang \ n", n,b), 3 output with front width and line wrapping

3. Code
4. Problems encountered in commissioning process and PTA submission List status note
    • Format error: Final output is not output in single-digit format

    • Workaround: The final output statement from printf ("%d meta:%d \ n", n,b); instead printf ("%3d:%3d zhang \ n", n,b);

Topic 3. Slicing expressions--write a Tokenizer 1. PTA Submission List
2. Design Ideas
    • 1. Define the character type variable A to hold the current character, b to hold a character in front of a
    • 2. Enter the character a, let B=a
    • 3.while Loop statement before the first character: if the first character a>= ' (' &&a<= '/' &&a!= '-' &&a!= ' + ', the newline output
      If the first character a== '-' | | | a== ' + ', no newline output
      If the first character a>= ' 0 ' &&a<= ' 9 ', no newline output
    • 4.while statement, conditional a not equal to '/n ' (newline), let B=a store a character, A=getchar () get the next new character
    • 5. If the current character A is a numeric character, does not wrap the output, the continue statement begins a new loop
      If the previous character B is a numeric character, the current A is the character '. ', then the line output is not wrapped, and the continue statement begins a new loop
      If the previous character, B, is a numeric character, the current character A is an operand, the first newline and then the output and then the newline, the continue statement begins a new loop
      If the previous character B is ' (', the current character A is '-', it must be negative, '-' does not wrap the output, the continue statement starts a new loop
      If the current character A is an operator other than '-', a newline is output, and the continue statement starts a new loop
      Judging the while loop condition based on the new characters read
3. Code

4. Problems in debugging process and PTA submission list The status of the explanation part is correct


The answer to these two places is wrong,

WORKAROUND: The first read of the word traits classes judgment: If the first character is ' + ' or '-', do not wrap the output, the following character to the subsequent program to judge

Second, this week's topic set PTA Final Ranking
Iii. Summary of this week's study 1. What have you learned? 1.1 How is a one-dimensional array defined and initialized?
  • Definition: Array type + array name +[array length] initialization: Data type + array name +[integer constant expression]={Initial value 1, initial value 2, ...}

    1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?

  • The array name is an address constant that holds the first address of the array memory space

    1.3 Why use arrays?
  • An array is an ordered set of data of the same type, which can be expressed and used repeatedly in a program, and is concise, readable, and easy to use looping structures.

    1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code Display
  • Selection method:

          1.将输入数依次赋给数组a的n个元素a[0]~a[n-1]      2.对n个数排序,for(k=0;k<n-1;k++) min=k min存放最小值所在下标      3.for(i=k+1;i<n;i++) 让i从后一项开始,如果a[i]<a[min],令a[i]与a[min]值互相交换      
  • Bubbling method:

          1.将输入数依次赋给数组a的n个元素a[0]—a[n-1]      2.对n个数排序,for(k=0;k<n-1;k++) max=k ,max存放最大值所在下标      3.for(i=0;i<n-1-i;i++) 让i从0开始,因为每次循环最后一项为最大数,故下次循环不需要再与上一次循环的最大项比较,所以每次少一项为n-i-1,如果a[i]>a[max],令a[i]与a[max]值互相交换      4.输出n个数组元素的值
  • Direct Insert Sort:

           1.将输入数依次赋给数组a的n个元素a[0]—a[n-1]       2.对n个数排序,for(k=1;k<n-1;k++) j=k       3.执行for(i=k;i>0;i--) 让i从k开始,再与之前的数组进行大小比较,如果比前一项小就互换两值,如果a[j]<a[i-1],令a[i]与a[i-1]值互相交换,j=i-1       
1.5 What is the binary search method? It differs from the order lookup method?
    • Binary search method: Define an array A, the first to find the number and the median of the array a comparison, if small, then take the left half of the median, (if large, then take the right half of the median), in the left half of the median to repeat this step, until found, otherwise when the left low> right-bound high, the output is not
      Difference: If the array A is unordered, and in the case of small amount of data, the order lookup is better than the binary search, but when the data volume is particularly large, and the array A is ordered, the binary search method is convenient and fast, the computation is much less than the sequential search, and the time to find the key words is less.

      1.6 How are two-dimensional arrays defined and initialized?
    • Definition: type name + array name +[]+[column Length]
    • Initialize: The initial value of the branch is assigned: int a [3] [3] ={{3}, {4,5,6}, {7,8,9}}, the order is assigned the initial value: int a [] [3] = {1,2,3,4,5,6,7,8,9}

      1.7 How is the matrix transpose implemented? In the matrix: the relationship between the row label I of the lower triangle, the upper triangle and the symmetric matrix J? Please indicate
    • With the main diagonal as the boundary, the row and column interchange
    • Lower triangle: i>=j
      Upper triangle: i<=j
      Symmetric matrix: I==j

      1.8 What is the general application of a two-dimensional array?
    • Primarily used to represent two-dimensional tables and matrices

2. This week's content, you are not what?
    • PTA in the segmentation sub-expression of the word this spent maths more time, the analysis of the special situation is more sluggish, a fault can not be found in time to come up with a response,
      may have to think for a while or even spend a whole day of time, on such topics are too little contact, problem-solving ideas are not clear, the ability to organize ideas also need to improve
    • In class school, in the implementation of the writing algorithm (in addition to the selection of sorting method) to achieve array sorting, there is no clear expression of their own meaning at the same time there are thinking wrong,
      There is their own pseudo-code too complex, let people see very annoying, they need to practice a simple and easy to understand the ability to write pseudo-code

C Language Blog Job-data type

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.