まだ動いていないOhgas' Fortune

小数か?小数が悪いのか?

#include <iostream>
using namespace std;


int main(){

  //入力系
  FILE *pfI;
  
  
  pfI= fopen("a.in","r");
  if(pfI== NULL){
    cout<<"a.inが開けません。"<<endl;
    return -1;
  }
  
  int n;
  fscanf(pfI,"%d",&n);
 


  //処理のループ
  for(int i=n;i>0;i--){
    //初期運用資金量、運用年数、運用の種類数
    int setmoney;
    int year,set;
    //お金
    double money;
    //単利・複利、手数料
    int ri,tesu;
    //年利率
    double nenri;
    //最大値
    int maxmoney=0;
    
    fscanf(pfI,"%d",&setmoney);
    fscanf(pfI,"%d",&year);
    fscanf(pfI,"%d",&set);
    
    cout<<"***************************************"<<endl;
    cout<<"初期運用資金"<<setmoney<<endl;
    cout<<"運用年数"<<year<<endl;
    cout<<"運用データセット数"<<set<<endl;

    //運用種類分処理を繰り返す。
    for(int m=set;m>0;m--){
      fscanf(pfI,"%d %lf %d",&ri,&nenri,&tesu);
     
      cout<<"単利か複利"<<ri<<endl;
      cout<<"年利率"<<nenri<<endl;
      cout<<"手数料"<<tesu<<endl;

      money=setmoney;
      int rishi=0;
      //運用年数分繰り返す      
      for(int y=year;y>0;y--){
	
	
	//単利の場合
	if(ri==0){
	  money=money+(int)(money*nenri)-tesu;
	}
	//複利の場合
	else{
	  //	  cout<<"複利の運用資金"<<money<<endl;
	  rishi+=(int)(money*nenri);
	  //cout<<"利子"<<rishi<<endl;
	  money=money-tesu;
	}
	
      }
      money=money+rishi;
     
      if(maxmoney<money) maxmoney=money;
      cout<<"最大金額は"<<maxmoney<<endl;
      
    }
   
  }



  return 0;
  
}