C Language Blog Job-data type

Source: Internet
Author: User

First, the PTA experimental work Problem 1:1. PTA Submission List

2. Design Ideas

Read the topic the biggest difficulty is to write a function that can invoke the topic table

    • (1) Define the variable A as the location code we want to enter.
    • (2) Enter the value of a.
    • (3) Call the function Chinese and pass the value of argument a to the function and leave it in function parameter a.
    • (4) The variables defined in the function b,c to preserve the first and second bytes of a, respectively.
    • (5) Observation table indicates the maximum number of rows is not more than 100
    • (6) therefore c=a%100,b=a/100.
    • (7) Output the first byte b+160 first, and then output the second byte of b+160.
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.

The subject is relatively simple is test instructions relatively difficult to understand, the topic is required to use C language in the original resources for programming, seriously read the question and there is no problem

Topic 2: Number falling into the trap 1. PTA Submission List

2. Design Ideas
    • (1) Define the function change is used to achieve a number of each digit number to be multiplied by 3 plus 1.
    • (2) Define the variable i=1 is used to control the loop, B is used to save the number of times I fall into the trap, and N is used to keep the number of i+1 fall into the trap
    • (3) First enter a N, and let B=n, to retain the 1th number
    • (4) Call the function change (n,i) and let the return value of N
    • (5) If the n=b ends the procedure;
    • (6) for (i=2;; i++)
    • (7) Call N=change (n,i);
    • (8) End the procedure when n=b; otherwise let b keep n;
    • (9) The following is a function of double change (int n,int i) written
    • (10) Defines the sum of each number of N as Sum=0;a used to hold each number of values;
    • (one) Do{a=n%10;n=n/10;sum+=a;} while (n!=0)
    • (12) Program return value sum*3+1.

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.


The first time a submission has a prompt error in place. The debugging process is as follows.

The original answer should be only one line. And then there are two lines. The reason is that I did not make a judgment outside of the loop. Cause errors.

Topic 3. Simple Calculator 1. PTA Submission List

2. Design Ideas
    • (1) Define the character type variable OP to hold the input character, and float variable A to keep each operand, and the last result sum,
    • (2) First enter a and use sum to retain a.
    • (3) while (1>0) {
    • (4) Enter an action character
    • (5) when op equals =, the output sum retains 0 decimal places and ends the program
    • (6) Outputs the next operand.
    • (7) if (o ' &&op!= '-' &&op!= '/' p== '/' &&a==0| | (op!= ' +&&op!= ') outputs the error and ends the program.
    • (8) When op== ' + ', then sum=a+sum;
    • (9) When op== '/', then sum=a/sum;
    • (10) When op== ', then sum=asum;
    • (11) When op== '-', then sum=a-sum;

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.


The two-time errors are resolved with the denominator of 0 and illegal characters respectively. The problem. The two problem-solving scenarios should be similar. That is, if it appears/(just division sign) to determine whether the floating-point variable behind it is 0. The second is that I take the subtraction out, as long as the character deformation is not equal to these characters will determine the error.

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?
1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?
1.3 Why use arrays?
1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
1.5 What is the binary search method? It differs from the order lookup method?
1.6 How are two-dimensional arrays defined and initialized?
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 state.
1.8 What is the general application of a two-dimensional array?

2. This week's content, you are not what?

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.