浙大PAT 1058
2016-02-28 13:15
387 查看
//水水的题目
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<string>
using namespace std;
//#define fin cin
int main()
{
/*ifstream fin("d:\in.txt" );
if (! fin.is_open())
{
cout << "Error opening file";
system("pause");
exit (1);
}*/
int g1=0,s1=0,k1=0,g2=0,s2=0,k2=0;
string a,b;
cin>>a>>b;
int i=0;
while(a[i]!='.')
{
g1=g1*10+a[i]-48;
i++;
}
i++;
while(a[i]!='.')
{
s1=s1*10+a[i]-48;
i++;
}
i++;
while(i<a.size())
{
k1=k1*10+a[i]-48;
i++;
}
i=0;
while(b[i]!='.')
{
g2=g2*10+b[i]-48;
i++;
}
i++;
while(b[i]!='.')
{
s2=s2*10+b[i]-48;
i++;
}
i++;
while(i<b.size())
{
k2=k2*10+b[i]-48;
i++;
}
int jw=0;
if(k1+k2>=29)
{
jw=1;
k1=k1+k2-29;
}
else
{
k1=k1+k2;
}
if(s1+s2+jw>=17)
{
s1=s1+s2+jw-17;
jw=1;
}
else
{
s1=s1+s2+jw;
jw=0;
}
g1=g1+g2+jw;
cout<<g1<<'.'<<s1<<'.'<<k1;
system("PAUSE");
return 0;
}
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<string>
using namespace std;
//#define fin cin
int main()
{
/*ifstream fin("d:\in.txt" );
if (! fin.is_open())
{
cout << "Error opening file";
system("pause");
exit (1);
}*/
int g1=0,s1=0,k1=0,g2=0,s2=0,k2=0;
string a,b;
cin>>a>>b;
int i=0;
while(a[i]!='.')
{
g1=g1*10+a[i]-48;
i++;
}
i++;
while(a[i]!='.')
{
s1=s1*10+a[i]-48;
i++;
}
i++;
while(i<a.size())
{
k1=k1*10+a[i]-48;
i++;
}
i=0;
while(b[i]!='.')
{
g2=g2*10+b[i]-48;
i++;
}
i++;
while(b[i]!='.')
{
s2=s2*10+b[i]-48;
i++;
}
i++;
while(i<b.size())
{
k2=k2*10+b[i]-48;
i++;
}
int jw=0;
if(k1+k2>=29)
{
jw=1;
k1=k1+k2-29;
}
else
{
k1=k1+k2;
}
if(s1+s2+jw>=17)
{
s1=s1+s2+jw-17;
jw=1;
}
else
{
s1=s1+s2+jw;
jw=0;
}
g1=g1+g2+jw;
cout<<g1<<'.'<<s1<<'.'<<k1;
system("PAUSE");
return 0;
}
相关文章推荐
- 浙大PAT1059 Prime Factors
- 浙大PAT1053
- 浙大PAT 1051
- 浙大pat1030
- 浙大PAT 1020. Tree Traversals (25)
- 4-1 简单输出整数
- 4-2 多项式求值
- Java 实现PAT乙级(Basic Level)1001-1010 解题报告(一)
- 浙大pat | 浙大pat乙级 1001~1004
- 浙大PAT甲级-1001
- 浙大PAT甲级-1002
- PAT 1034
- PAT 1087
- PAT 1091
- PAT 1110
- PAT 1111
- 写出这个数 (20)
- 写出这个数 (20),PAT(Basic Level) Practise NO.1002
- 卡拉兹猜想
- 卡拉兹(Callatz)猜想,PAT(Basic Level) Practise NO.1001