小数点后第n位

小数点后第n位

Description

输入正整数n,计算355除以113小数点后的第n位。

Input

输入一个正整数n

Output

输出小数点后第n位的结果。

Sample Input 1 

2

Sample Output 1

4

Sample Input 2 

999998

Sample Output 2

7
      我的思路

  啊!这是道经典的模拟题!                                                                                                                                                                方法:边吃(除)边扔

   


      我的代码

   

  Lauguage

  C++

   Code

#include <iostream>
const int chu=113;
using namespace std;
int main()
{
int e=355;
int n=0;
cin>>n;
for(int i=1;i<=n;i++)
{
	e=(e-chu*(e/chu))*10;
}
cout<<e/chu;

	return 0;
 }


   



BYE~



posted @ 2018-05-15 21:06  SMALLff  阅读(383)  评论(0编辑  收藏  举报