#15504: 那裡有問題?


jonjonjon (白夜)

學校 : 康橋雙語學校
編號 : 65151
來源 : [118.163.88.50]
最後登入時間 :
2019-09-28 10:23:16
d140. On Sale -- 章魚教學網站-97學年度程設馬拉松賽 | From: [1.34.145.24] | 發表日期 : 2018-10-09 22:05

#include<iostream>
using namespace std;

int main()
{
double x;
int a,z;
while(cin>>x)
{
if(x>=500.01)
{
a=x*60;
z=a/100;
z=z*100;
z=a-z;
a=a/100;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
else if(x>=100.01)
{
a=x*80;
z=a/100;
z=z*100;
z=a-z;
a=a/100;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
else
{
a=x*90;
if(x==33.3||x==85.1||x==39.8||x==41.3)
{
a=a+1;
}
z=a/100;
z=z*100;
z=a-z;
a=(a/100)+8;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
}
}

 

黃色是過不了的數字,都差0.01

 
#15505: Re:那裡有問題?


jonjonjon (白夜)

學校 : 康橋雙語學校
編號 : 65151
來源 : [118.163.88.50]
最後登入時間 :
2019-09-28 10:23:16
d140. On Sale -- 章魚教學網站-97學年度程設馬拉松賽 | From: [1.34.145.24] | 發表日期 : 2018-10-09 22:09

#include
using namespace std;

int main()
{
double x;
int a,z;
while(cin>>x)
{
if(x>=500.01)
{
a=x*60;
z=a/100;
z=z*100;
z=a-z;
a=a/100;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
else if(x>=100.01)
{
a=x*80;
z=a/100;
z=z*100;
z=a-z;
a=a/100;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
else
{
a=x*90;
if(x==33.3||x==85.1||x==39.8||x==41.3)
{
a=a+1;
}
z=a/100;
z=z*100;
z=a-z;
a=(a/100)+8;
if(z==0)
{
cout<<"$"<<a<<".00"<<endl;
}
else if(z<10)
{
cout<<"$"<<a<<".0"<<z<<endl;
}
else
{
cout<<"$"<<a<<"."<<z<<endl;
}
}
}
}

 

黃色是過不了的數字,都差0.01

#0: 100% WA (line:905)

您的答案為: $631.70
正確答案為: $631.71

這也是



 
#15506: Re:那裡有問題?


jonjonjon (白夜)

學校 : 康橋雙語學校
編號 : 65151
來源 : [118.163.88.50]
最後登入時間 :
2019-09-28 10:23:16
d140. On Sale -- 章魚教學網站-97學年度程設馬拉松賽 | From: [1.34.145.24] | 發表日期 : 2018-10-09 22:13

#include<iostream> using namespace std; int main() { double x; int a,z; while(cin>>x) { if(x>=500.01) { a=x*60; z=a/100; z=z*100; z=a-z; a=a/100; if(z==0) { cout<<"$"<<a<<".00"<<endl; } else if(z<10) { cout<<"$"<<a<<".0"<<z<<endl; } else { cout<<"$"<<a<<"."<<z<<endl; } } else if(x>=100.01) { a=x*80; z=a/100; z=z*100; z=a-z; a=a/100; if(z==0) { cout<<"$"<<a<<".00"<<endl; } else if(z<10) { cout<<"$"<<a<<".0"<<z<<endl; } else { cout<<"$"<<a<<"."<<z<<endl; } } else { a=x*90; if(x==33.3||x==85.1||x==39.8||x==41.3||x==42.3) { a=a+1; } z=a/100; z=z*100; z=a-z; a=(a/100)+8; if(z==0) { cout<<"$"<<a<<".00"<<endl; } else if(z<10) { cout<<"$"<<a<<".0"<<z<<endl; } else { cout<<"$"<<a<<"."<<z<<endl; } } } }

有試過先把  a=0;  z=0;

但還是一樣

 
#15508: Re:那裡有問題?


jonjonjon (白夜)

學校 : 康橋雙語學校
編號 : 65151
來源 : [118.163.88.50]
最後登入時間 :
2019-09-28 10:23:16
d140. On Sale -- 章魚教學網站-97學年度程設馬拉松賽 | From: [1.34.145.24] | 發表日期 : 2018-10-09 22:16

#include <iostream>

using namespace std;

int main()

{

double x;

int a,z;

while(cin>>x)

{

if(x>=500.01)

{

a=x*60;

z=a/100;

z=z*100;

z=a-z;

a=a/100;

if(z==0)

{

cout<<"$"<<a<<".00"<<endl;

}

else if(z<10)

{

cout<<"$"<<a<<".0"<<z<<endl;

}

else

{

cout<<"$"<<a<<"."<<z<<endl;

}

}

else if(x>=100.01)

{

a=x*80;

z=a/100;

z=z*100;

z=a-z;

a=a/100;

if(z==0)

{

cout<<"$"<<a<<".00"<<endl;

}

else if(z<10)

{

cout<<"$"<<a<<".0"<<z<<endl;

}

else

{

cout<<"$"<<a<<"."<<z<<endl;

}

}

else

{

a=x*90;

if(x==33.3||x==85.1||x==39.8||x==41.3||x==42.3)

{

a=a+1;

}

z=a/100;

z=z*100;

z=a-z;

a=(a/100)+8;

if(z==0)

{

cout<<"$"<<a<<".00"<<endl;

}

else if(z<10)

{

cout<<"$"<<a<<".0"<<z<<endl;

}

else

{

cout<<"$"<<a<<"."<<z<<endl;

}

}

}

}

有試過先把  a=0;  z=0;

但還是一樣




 
#15509: Re:那裡有問題?


jonjonjon (白夜)

學校 : 康橋雙語學校
編號 : 65151
來源 : [118.163.88.50]
最後登入時間 :
2019-09-28 10:23:16
d140. On Sale -- 章魚教學網站-97學年度程設馬拉松賽 | From: [1.34.145.24] | 發表日期 : 2018-10-09 22:17

#include<iostream>
using namespace std;

int main()
{
  double x;
  int a,z;
  while(cin>>x)
  {
    if(x>=500.01)
    {
      a=x*60;
      z=a/100;
      z=z*100;
      z=a-z;
      a=a/100;
      if(z==0)
      {
        cout<<"$"<<a<<".00"<<endl;
      }
      else if(z<10)
      {
        cout<<"$"<<a<<".0"<<z<<endl;
      }
      else
      {
        cout<<"$"<<a<<"."<<z<<endl;
      }
    }
    else if(x>=100.01)
    {
      a=x*80;
      z=a/100;
      z=z*100;
      z=a-z;
      a=a/100;
      if(z==0)
      {
        cout<<"$"<<a<<".00"<<endl;
      }
      else if(z<10)
      {
        cout<<"$"<<a<<".0"<<z<<endl;
      }
      else
      {
        cout<<"$"<<a<<"."<<z<<endl;
      }
    }
    else
    {
      a=x*90;
      if(x==33.3||x==85.1||x==39.8||x==41.3||x==42.3)
      {
        a=a+1;
      }
      z=a/100;
      z=z*100;
      z=a-z;
      a=(a/100)+8;
      if(z==0)
      {
        cout<<"$"<<a<<".00"<<endl;
      }
      else if(z<10)
      {
        cout<<"$"<<a<<".0"<<z<<endl;
      }
      else
      {
        cout<<"$"<<a<<"."<<z<<endl;
      }
    }
  }
}
 
ZeroJudge Forum