当前位置:网站首页>[introduction to C language] zzulioj 1016-1020

[introduction to C language] zzulioj 1016-1020

2022-07-25 21:09:00 Death margin~

ZZULIOJ 1016: bank rate

Title Description

Set up a bank 1 The annual interest rate of one-year fixed deposit is 2.25%, The deposit principal is capital element , Try to program, calculate and output n The sum of capital and profit after years .

( notes :  At present, the interest of bank current deposits is calculated by simple interest . If it's a time deposit , Transfer the principal and interest to the next deposit period , Then it will continue to be included in the regular , Equivalent to compound interest .)

Input

Enter a positive integer and a real number , Respectively represents the number of years of deposit and the principal of deposit .

Output

Output a real number as n The sum of capital and profit after years , After the decimal point 6 Digit number .

The sample input

2 100.0

Sample output

104.550625
#include <stdio.h>#include <stdlib.h> int main(){   int n;    double c;    scanf("%d %lf",&n,&c);    printf("%.6f\n",c*pow(1+0.0225,n));    return 0;}

ZZULIOJ 1017: Determine the number of positive integer digits

Title Description

Give one no more than 5 Bit positive integer , Judge how many digits it is , And the output .

Input

One no more than 5 Bit positive integer . 

Output

Output the number of bits of a positive integer , Take a line alone .

The sample input

111

Sample output

3

Tips

Using functions log10(n), Find out n The to 10 Log base , The integer part of this logarithm , Namely n The index in scientific counting , Add this integer 1 Namely n Number of digits .

#include <stdio.h>#include <stdlib.h> int main(){
       int m,n;    scanf("%d",&m);    for(n=0;m>0;n++)    {
           m=m/10;    }    printf("%d\n",n);    return 0;}

ZZULIOJ 1018: Odd even

Title Description

Enter an integer , Judge whether the number is odd or even .

Input

Input integer n.

Output

Output if the number is odd “odd”, Even numbers output “even”( The output does not contain double quotes ).

The sample input

-3

Sample output

odd
#include <stdio.h>#include <stdlib.h> int main(){
       int m;    scanf("%d",&m);    if(m%2==0)        printf("even");    else        printf("odd");     return 0;}

ZZULIOJ 1019: Park tickets

Title Description

The ticket price of a park is per person 50 element , One time ticket full 30 Zhang , You can charge less each 2 element . Try to write the program of automatic billing system .

Input

  Enter a positive integer , Indicates the number of tickets purchased .

Output

Output an integer , Indicates the amount that the user actually needs to pay .

The sample input

30

Sample output

1440
#include <stdio.h>#include <stdlib.h> int main(){
       int m,n;    scanf("%d",&m);    if(m>=30)        n=48*m;    else        n=50*m;    printf("%d",n);     return 0;}

ZZULIOJ 1020: Two integer sort

Title Description

Enter two integers from the keyboard x,y, Output their values in descending order .

Input

Enter two integers x,y.

Output

Output their values in descending order . Data is separated by spaces .

The sample input

20 16

Sample output

16 20
#include <stdio.h>#include <stdlib.h> int main(){   int x,y;    scanf("%d %d",&x,&y);    if(x<y){
       printf("%d %d",x,y);    }else{
       printf("%d %d",y,x);    }     return 0;}
原网站

版权声明
本文为[Death margin~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/206/202207252108487818.html