L1-058 6翻了
#include <iostream>
using namespace std;
int main()
{
string str;
int ans=0,cnt=0;
getline(cin, str);
int len = str.size();
for(int i=0;i<len;i++){
if(str[i]=='6'){
cnt=1;
for(int j=i+1;str[j]=='6';j++){
cnt++;
}
i=cnt+i-1;
if(cnt>3&&cnt<=9){
cout << '9';
}else if(cnt>9){
cout << "27";
}else{
while(cnt--){
cout << '6';
}
}
}else{
cout << str[i];
}
}
cout << endl;
return 0;
}
L1-060 心理阴影面积
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,y;
cin >> x >> y;
double s1,s2,s3,s;
s1 = x*y/2;
s2 = (100-x)*(100-y)/2;
s3 = (100-x)*y;
s = 5000-s1-s2-s3;
cout << s << endl;
return 0;
}
L1-061 新胖子公式
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double x,y;
cin >> x >> y;
double s = x/(y*y);
if(s>25){
printf("%.1f\n",s);
cout << "PANG" << endl;
}else{
printf("%.1f\n",s);
cout << "Hai Xing" << endl;
}
return 0;
}
L1-062 幸运彩票
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N[200]={0};
int n;
cin >> n;
for(int i=0;i<n;i++){
cin >> N[i];
}
for(int i=0;i<n;i++){
int n1=N[i]/100000+N[i]/10000%10+N[i]/1000%10;
int n2=N[i]/100%10+N[i]/10%10+N[i]%10;
if(n1==n2){
cout << "You are lucky!" << endl;
}else{
cout << "Wish you good luck." << endl;
}
}
return 0;
}