The first homework 3 classes 09

Problem 7-2 Digits of Integer 152 

1. Experimental code

#include<stdio.h>
int main()
{
    printf("152 = 2 + 5*10 + 1*100");
    return 0;
}

 

2 Design ideas

(1)
The first step: define the main function;

Step 2: Use the printf function to print the desired content;

Step 3: Enter return 0 to return;

(2) Flowchart

3. Problems encountered in the debugging process of this question and solutions

no problem

Topic 7-6 Calculating personal income tax

1. Experimental code

#include <stdio.h>
int main(void)
{
    int x;
    double y;
    scanf("%d",&x);
    if(x<=1600){
        y = 0 ;
    }
    else if(x<=2500){
        y =(x- 1600 )* 0.05 ;
    }
     else if(x<=3500){
        y =(x- 1600 )* 0.1 ;
    }
     else if(x<=4500){
        y =(x- 1600 )* 0.15 ;
    }
    else{
        y =(x- 1600 )* 0.2 ;
    }    
    printf("%.2f",y);
    return 0;
}

 

2 Design ideas

(1)
The first step: define the main function

Step 2: Define the variable xy

Step 3: Input with scanf

Step 4: Use if else to judge

Step 5: Output Results
(2) Flowchart

3. Problems encountered in the debugging process of this question and solutions

Forget that floating-point type output needs to be output with .f, and replace %d with %.2f.

2. Summary and learning progress bar

1. Summarize what you have learned in the past few weeks, the problems encountered and the solutions.

 I've been learning various statements and functions in the last few weeks, learning how to input and output, as well as conditional and looping structures

I also had some problems in my study, such as some compilation errors when writing programs, writing %lf to %f when double floating-point type input, etc., mainly due to less usual operations and less programming after class , which improved after some programming practice

2. Comment on the homework of 3 classmates this week (give a hyperlink to the commented classmate's blog in the homework! Hyperlink!), and invite 3 classmates to comment on your homework. If there is no comment, the score will be deducted for the question.

https://www.cnblogs.com/hhh-98/p/10991759.html

https://www.cnblogs.com/kilakila/p/11011714.html

 

https://www.cnblogs.com/rinko/p/11021348.html

 

Reprinted in: https://www.cnblogs.com/sun0326/p/11013242.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324152475&siteId=291194637