当前位置:网站首页>Electronic Association C language level 1 35, bank interest

Electronic Association C language level 1 35, bank interest

2022-07-04 06:59:00 dllglvzhenfeng

Electronics Association C Language 1 level  35 、 Bank interest

OpenJudge - 15: Bank interest

OpenJudge - 2390: Bank interest


C++ Code   Method 1

/*
 Electronics Association  C Language  1 level   35 、 Bank interest 
http://noi.openjudge.cn/ch0105/15/
http://bailian.openjudge.cn/practice/2390/

 Farmer John made a lot of money last year ! He wants to invest the money , And how much you can get 
 Yi is curious . The compound annual interest rate of the known investment is  R(0  To  20  Integer between ). John's current total value is  M  Of 
 money (100  To  1,000,000  Integer between ). He clearly knows he wants to invest  Y  year ( Range  0  To  400).
 Please help him calculate how much money he will have in the end , And output its integer part . The data guarantees that the output results are in  32  You have 
 Within the range of signed integers .
 Input 
 A line contains three integers  R,M,Y, Two adjacent integers are separated by a single space .
 Output 
 An integer , That is, how much money John eventually has ( Integral part ).
 The sample input 

5 5000 4
 Sample output 
6077
 Tips 
 In the example ,
 After the first year : 1.05 * 5000 = 5250
 Second years later : 1.05 * 5250 = 5512.5
 After the third year : 1.05 * 5512.50 = 5788.125
 After the fourth year : 1.05 * 5788.125 = 6077.53125
6077.53125  The integer part of is  6077.
 source :USACO 2004 November
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,r,m,y;
	double sum;
	
	scanf("%d%d%d",&r,&m,&y);
	
	sum=m;
	
	for(i=1;i<=y;i++)
	{
		sum=sum*(1+0.01*r);
	}
	
	printf("%d",(int)sum);
	
	return 0;
}


C++ Code   Method 2

/*
1.5 Cycle control of programming basis _15 Bank interest   Method 2  
http://noi.openjudge.cn/ch0105/15/
*/
#include <iostream>  
#include <iomanip>  
using namespace std;  
int main()  
{  
    int R, M, Y;  
    double money;
	  
    cin >> R >> M >> Y;  
    
	money = M;  
    for (int i=0; i<Y; i++)
	{  
        money *= (100+R)/100.0;  
    }
	  
    cout << (int)money << endl;
	  
    return 0;  
}  


C++ Code : Method 3

/*
1.5 Cycle control of programming basis _15 Bank interest   Method 3  
http://noi.openjudge.cn/ch0105/15/
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{ 
	int R,Y;
	long long M;
	
	cin>>R>>M>>Y;
	
	M=M*pow(1+R*0.01,Y);
	
	cout<<M;
	
	return 0;
}


python3 Code :

l = list(map(float, input().split()))

R = l[0];M = l[1];Y = l[2]

i = 1
money = M
while i <= Y:
            i += 1
            money *= 1 + R / 100
print(int(money))

#writen by XiaoMaFenJu


Baby's programming series

Baby's programming series _dllglvzhenfeng The blog of -CSDN Blog

Baby's Physics Series

Baby's Physics Series _dllglvzhenfeng The blog of -CSDN Blog

Baby's math books

Baby's math books _dllglvzhenfeng The blog of -CSDN Blog

《 Mathematics and life 》 Of 3 books

《 Mathematics and life 》 Of 3 books _dllglvzhenfeng The blog of -CSDN Blog

Math girl series

Math girl series _dllglvzhenfeng The blog of -CSDN Blog

Rationalism : Mathematics photo album series books, etc

Rationalism : Mathematics photo album series books, etc _dllglvzhenfeng The blog of -CSDN Blog




Recommend several introductory books on calculus

Recommend several introductory books on calculus _dllglvzhenfeng The blog of -CSDN Blog _ Introduction to calculus

linear algebra 、 probability Introduction book recommendation

linear algebra 、 probability Introduction book recommendation _dllglvzhenfeng The blog of -CSDN Blog _ Recommended books on linear algebra

Introduction to combinatorics books

Introduction to combinatorics books _dllglvzhenfeng The blog of -CSDN Blog

Introduction to group theory

Introduction to group theory _dllglvzhenfeng The blog of -CSDN Blog _ Introduction to group theory

Combinatorial mathematics —— ***

Combinatorial mathematics —— *** _mumei314 The blog of -CSDN Blog

Rubik's cube and group theory

Rubik's cube and group theory _ Blog on the beauty of algorithms and Mathematics -CSDN Blog

Understanding Euler formula from the perspective of group theory

Understanding Euler formula from the perspective of group theory _MatheMagician The blog of -CSDN Blog



Mathematics in Xinao : stirling numbers 、 Carter LAN number

Mathematics in Xinao : stirling numbers 、 Carter LAN number _dllglvzhenfeng The blog of -CSDN Blog

Mathematics in Xinao : The generating function

Mathematics in Xinao : The generating function _dllglvzhenfeng The blog of -CSDN Blog

Mathematics in Xinao : Sun Tzu's Theorem Chinese remainder theorem

Mathematics in Xinao : Sun Tzu's Theorem Chinese remainder theorem _dllglvzhenfeng The blog of -CSDN Blog

Mathematics in Xinao : Unique decomposition theorem

Mathematics in Xinao : Unique decomposition theorem _dllglvzhenfeng The blog of -CSDN Blog

In Xinao “ cheat ” Divine skill ---“ The meter ”

In Xinao “ cheat ” Divine skill ---“ The meter ”_dllglvzhenfeng The blog of -CSDN Blog _ Type a table to save one

Mobius inversion Balanced planning Double stack deque Equivalence classes, etc

Mobius inversion Balanced planning Double stack deque Equivalence classes, etc _dllglvzhenfeng The blog of -CSDN Blog

原网站

版权声明
本文为[dllglvzhenfeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207040657276044.html