1010题目:
http://ac.jobdu.com/problem.php?pid=1010
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#define ISYEAP(x) x%100!=0 && x%4==0 || x%400==0 ? 1:0
using namespace std;
char s[110];
int figure1,figure2;
void thenum(int which,int numb){
if(which==0){
figure1=figure1*10+numb;
}
else{
figure2=figure2*10+numb;
}
return ;
}
void divide(){
int len=strlen(s);
figure1=0;
figure2=0;
int flag=0;
int temp=0;
for(int i=0;i<len;i++){
temp=0;
if(s[i]=='+')
{
flag=1;//进行计算第二个数
// cout<<"i="<<i<<endl;
continue;
}
if(s[i]=='=')
continue;
if(s[i]==' ')
continue;
switch (s[i]){
case 'z':temp=0;
i+=3;
break;
case 'o':temp=1;
i+=2;
break;
case 't':if(s[i+1]=='w'){
i+=2;
temp=2;
}
else{
i+=4;
temp=3;
}
break;
case 'f': if(s[i+1]=='o'){
i+=3;
temp=4;
}
else{
i+=3;
temp=5;
}
break;
case 's': if(s[i+1]=='i'){
i+=2;
temp=6;
}
else{
i+=4;
temp=7;
}
break;
case 'e': i+=5;
temp=8;
break;
case 'n': i+=3;
temp=9;
break;
default: break;
}
thenum(flag,temp);
}
// cout<<"figure1="<<figure1<<" figure2="<<figure2<<endl;
}
void calculate(){
cout<<figure1+figure2<<endl;
}
int main(){
while(1){
gets(s);
divide();
if(figure1==0 && figure2==0)
break;
calculate();
}
return 0;
}
/**************************************************************
Problem: 1010
User: zhouyudut
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
1015题目:
http://ac.jobdu.com/problem.php?pid=1015
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#define ISYEAP(x) x%100!=0 && x%4==0 || x%400==0 ? 1:0
using namespace std;
int m,n,k;
bool judge(){
int tempm=m%(int)pow(10,k);
int tempn=n%(int)pow(10,k);
if(tempn==tempm)
return false;
return true;
}
int main()
{
while(1){
scanf("%d%d%d",&m,&n,&k);
if(m==0 && n== 0)
return 0;
if(judge()){
cout<<m+n<<endl;
}
else{
cout<<"-1"<<endl;
}
}
return 0;
}
/**************************************************************
Problem: 1015
User: zhouyudut
Language: C++
Result: Accepted
Time:0 ms
Memory:1608 kb
****************************************************************/