每日三百行代码 第七天
2019天梯赛一级题
- L1-1 PTA使我精神焕发 (5 分)
- L1-2 6翻了 (15 分)
- L1-3 敲笨钟 (20 分)
- L1-4 心理阴影面积 (5 分)
- L1-5 新胖子公式 (10 分)
- L1-6 幸运彩票 (15 分)
- L1-7 吃鱼还是吃肉 (10 分)
- L1-8 估值一亿的AI核心代码 (20 分)
#include<stdio.h>
int main(){
printf("PTA shi3 wo3 jing1 shen2 huan4 fa1 !");
return 0;
}
#include<stdio.h>
#include<string.h>
int main(){
char m[1001];
int count=0;
gets(m);
int n=strlen(m);
for(int i=0;i<=n;i++){
if(m[i]=='6'){
count++;
}
else{
if(count>9){
printf("27");
}
else if(count>3){
printf("9");
}
else {
while(count--){
printf("6");
}
}
count=0;
printf("%c",m[i]);
}
}
printf("\n");
return 0;
}
#include<stdio.h>
#include<string.h>
int judge(char a[][101],int row){
int j=0;
char temp[]={
"ong,"};
char t[]={
"ong."};
if (strstr(a[row],temp)!=0){
if(strstr(a[row],t)!=0){
return 1;
}
}
return 0;
}
int main(void){
char input[21][101]={
0};
int n=0,i=0;
scanf("%d",&n);
getchar();
for(i=0;i<n;i++){
gets(input[i]);
}
for(i=0;i<n;i++){
if(judge(input,i)){
int j=0;
int cnt=strlen(input[i]);
int blank=0;
char insert[]={
"qiao ben zhong."};
for(j=cnt-1;;j--){
if(input[i][j]==' '){
blank++;
}
if(input[i][j]==','){
blank++;
}
if(blank==3){
j++;
break;
}
}
strcpy(input[i]+j,insert);
printf("%s\n",input[i]);
}
else{
printf("Skipped\n");
}
}
return 0;
}
#include<stdio.h>
int main(){
int x,y;
scanf("%d %d",&x,&y);
int s,s1,s2;
s1=y*100;
s2=(100-x)*100;
s=5000-(s1/2)-(s2/2);
printf("%d",s);
return 0;
}
#include<stdio.h>
int main(){
double m,h;
scanf("%lf %lf",&m,&h);
double num;
num=m/(h*h);
if(num>25.0){
printf("%.1lf\n",num);
printf("PANG\n");
}else{
printf("%.1lf\n",num);
printf("Hai Xing\n");
}
return 0;
}
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
char m[10];
for(int i=0;i<n;i++){
scanf("%s",m);
int num[6];
for(int j=0;j<6;j++){
num[j]=m[j]-'0';
}
if((num[0]+num[1]+num[2])==(num[3]+num[4]+num[5])){
printf("You are lucky!\n");
}else{
printf("Wish you good luck.\n");
}
}
return 0;
}
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int x,h,m;
scanf("%d %d %d",&x,&h,&m);
if(x==1){
if(h>130){
printf("ni li hai! ");
}else if(h==130){
printf("wan mei! ");
}else{
printf("duo chi yu! ");
}
if(m>27){
printf("shao chi rou!");
}else if(m==27){
printf("wan mei!");
}else{
printf("duo chi rou!");
}
printf("\n");
}
else{
if(h>129){
printf("ni li hai! ");
}else if(h==129){
printf("wan mei! ");
}else{
printf("duo chi yu! ");
}
if(m>25){
printf("shao chi rou!");
}else if(m==25){
printf("wan mei!");
}else{
printf("duo chi rou!");
}
printf("\n");
}
}
return 0;
}
#include <stdio.h>
#include <string.h>
int iszf(char a){
if(a>='0' && a<='9'){
return 1;
}
if(a>='a' && a<='z'){
return 1;
}
if(a>='A' && a<='Z'){
return 1;
}
return 0;
}
char zxxx(char a){
if(a>='A' && a<='Z'){
if(a=='I'){
return 'I';
}else{
return a+32;
}
}
return a;
}
int main(){
int n;
scanf("%d\n",&n);
while(n--){
char a[1010],b[1010];
int la=0,lb=0;
gets(a);
printf("%s\n",a);
la=strlen(a);
int lk=0;
int ff=0;
for(int i=0;i<la;i++){
if(a[i]==' '){
lk++;
}else if(!iszf(a[i])){
lk=0;
ff=1;
b[lb++]=zxxx(a[i]);
}else{
if(lk>0 && ff){
b[lb++]=' ';
}
lk=0;
ff=1;
b[lb++]=zxxx(a[i]);
}
}
b[lb]=0;
printf("AI: ");
for(int i=0;i<lb;i++){
if((b[i]=='I')&&
(i==0||!iszf(b[i-1]))&&
(!iszf(b[i+1]))
){
printf("you");
}else if( (b[i]=='m'&&b[i+1]=='e')&&
(i==0||!iszf(b[i-1]))&&
(!iszf(b[i+2]))
){
printf("you");
i+=1;
}else if(b[i]=='?'){
printf("!");
}else if( (b[i]=='c'&&b[i+1]=='a'&&b[i+2]=='n'&&b[i+3]==' '&&b[i+4]=='y'&&b[i+5]=='o'&&b[i+6]=='u')&&
(i==0||!iszf(b[i-1]))&&
(!iszf(b[i+7]))
){
printf("I can");
i+=6;
}else if( (b[i]=='c'&&b[i+1]=='o'&&b[i+2]=='u'&&b[i+3]=='l'&&b[i+4]=='d'&&b[i+5]==' '&&b[i+6]=='y'&&b[i+7]=='o'&&b[i+8]=='u')&&
(i==0||!iszf(b[i-1]))&&
(!iszf(b[i+9]))
){
printf("I could");
i+=8;
}
else{
printf("%c",b[i]);
}
}
printf("\n");
}
return 0;
}