The Marshtomp has seen it all before
来源:互联网 发布:淘宝品牌男装授权 编辑:程序博客网 时间:2024/06/04 23:23
简单题 dbug几个小时···········
教训
~~~~~
错误代码
#include<stdio.h>#include<string.h>char a[10000];int main(){ while(gets(a)) { int len; len=strlen(a); for(int i=0; i<len; i++) { if(a[i]=='m'||a[i]=='M') { if(a[i+1]=='a'||a[i+1]=='A') { if(a[i+2]=='r'||a[i+2]=='R') { if(a[i+3]=='s'||a[i+3]=='S') { if(a[i+4]=='h'||a[i+4]=='H') { if(a[i+5]=='t'||a[i+5]=='T') { if(a[i+6]=='o'||a[i+6]=='O') { if(a[i+7]=='m'||a[i+7]=='M') { if(a[i+8]=='p'||a[i+8]=='P') { i=i+8; printf("fjxmlhx"); } } } } } } } } } else { printf("%c",a[i]); } } printf("\n"); } return 0;}
下面分析错误原因
如果只输入m由于先判断第一个if 进入if 可是后面的又不符合,于是下面的else也无法输出
m这个数相当于让吞了
肯定WA了
AC代码
#include <stdio.h> #include <string.h> int main() { char a[10000]; int s; while(gets(a)) { for(int i=0; i<strlen(a); i++) { s=0; if(a[i]=='m'||a[i]=='M') s++; if(a[i+1]=='a'||a[i+1]=='A') s++; if(a[i+2]=='r'||a[i+2]=='R') s++; if(a[i+3]=='s'||a[i+3]=='S') s++; if(a[i+4]=='h'||a[i+4]=='H') s++; if(a[i+5]=='t'||a[i+5]=='T') s++; if(a[i+6]=='o'||a[i+6]=='O') s++; if(a[i+7]=='m'||a[i+7]=='M') s++; if(a[i+8]=='p'||a[i+8]=='P') s++; if(s==9) printf("fjxmlhx"),i+=8; else printf("%c",a[i]); } printf("\n"); } return 0; }
0 0
- The Marshtomp has seen it all before
- The Marshtomp has seen it all before
- # hihocoder #1082 : The Marshtomp has seen it all before
- E - The Marshtomp has seen it all before
- The Marshtomp has seen it all before(c/c++字符串输入处理)
- Analyzing Linux kernel crash dumps with crash - The one tutorial that has it all
- Analyzing Linux kernel crash dumps with crash - The one tutorial that has it all
- The maximum recursion 100 has been exhausted before statement completion
- It is All About The Data
- It's All In The Mind
- hdu5742 It's All In The Mind
- 5742 ( It's All In The Mind )
- HDU5742 It's All In The Mind
- hdu5742 It's All In The Mind
- hdoj5742 It's All In The Mind
- It's All In The Mind
- It's All In The Mind HDU
- This is it——Hasn't see it before all
- 两台设备连接在同一Wi-Fi不能通信问题解决
- DFS.H4403.等式成立
- peachfuzz
- unity网格合并后位置会变
- Intent传递数据
- The Marshtomp has seen it all before
- 可滑动Header控件的实现
- 【Dongle】【Java】基础(一)之输出
- 【Leecode】207Validate Binary Search Tree有效二叉搜索树
- swift LOG 输出
- (44)类的作用域
- C语言——分解质因数
- 关于SVM一篇比较全介绍的博文
- 有感