In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "C language simple topic example analysis", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "C language simple topic example analysis" bar!
Title
Topic description
For customers with the same principal repayment model, write a program to input the total loan amount (ten thousand yuan in units), monthly interest rate, total loan months, and output the customer repayment amount in the first month (in yuan, take integers).
The formula for calculating the equal principal is as follows:
Monthly repayment amount = (loan principal / total months of repayment) + (principal-accumulated principal repaid) x monthly interest rate
Input
Enter the total loan (integer, unit: ten thousand yuan), the monthly interest rate (floating point), and the total number of months of loan (integer)
Output
Monthly repayment amount (round number, unit: yuan)
I will not talk about the first few topics, it is really too simple, this topic is also very simple, but I was rubbed is not optimistic about the topic, I first took a pen to write like this on paper. Pay no attention to the topic output the amount of customer repayment in the first month
Moreover, I didn't write it. I didn't write it until I went to the bathroom.
My initial answer was
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
Printf ("% d\ n", i*10000*a+a*10000/b)
Return
}
Result output
Later, I changed it to (the opponent handed in the answer and walked past me. I got up and changed it after I went to the bathroom.)
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
S = i*10000*a+a*10000/b
Printf ("% d\ n", s)
Return
}
At this point, I don't understand why I have to use a variable to receive data. Looking at my colleagues handing in their papers one by one, I felt very bad about being rubbed. At that time, alas, I went to the toilet silently, and they were still discussing it when they finished writing. I became more nervous. This little bit, that little bit, time passed.
Later, when it was over, I believed that this would be all right.
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
S = i*10000*a+a*10000/b
Printf ("% f\ n", i*10000*a+a*10000/b)
Return
}
But after this, there are a lot of decimal points that do not meet the requirements, casually change it to the following
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
S = i*10000*a+a*10000/b
Printf ("% 3.2f\ n", i*10000*a+a*10000/b)
Return
}
See that the output length has also changed to 2.
Change it again
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
Printf ("% 3.0f\ n", i*10000*a+a*10000/b)
Return
}
Output
This is correct, but why is it so before?
Read the article
Detailed explanation of embedded Linux:C language printf
Zhuanlan.zhihu.com
So if you change it like this,
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
Printf ("% 7.0f\ n", i*10000*a+a*10000/b)
Return
}
Output
Finish
Supplement
I couldn't understand why the mandatory type didn't take effect, so I couldn't sleep now. I must have been nervous about what was wrong and didn't correct it in time. I thought about it, and it was OK to write like this.
# include
Intmain ()
{
Inta,b
Floati =
Ints
Scanf ("% d% f% d", & a% d% f% d)
Printf ("% d\ n", (int) (i*10000*a+a*10000/b))
Return
}
At this point, I believe you have a deeper understanding of "C language simple topic example Analysis". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.