HDU1409 Is It a Number
http://acm.hdu.edu.cn/showproblem.php?pid=1409
没啥好说的,至今也不知道到底错在哪里了,看了discuss才过的
1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <vector> 5 #include <string.h> 6 #include <map> 7 using namespace std; 8 char s[12345]; 9 int solve(char *s){ 10 int i=0; 11 int len=strlen(s); 12 while(s[i]>='0'&&s[i]<='9'){ 13 i++; 14 } 15 16 if(i==len){ 17 return 1; 18 } 19 if(s[i]=='.'){ 20 i++; 21 while(s[i]>='0'&&s[i]<='9'){ 22 i++; 23 } 24 if(i==len){ 25 return 1; 26 } 27 if(s[i]=='E'){ 28 i++; 29 if(s[i]=='+'||s[i]=='-'){ 30 i++; 31 } 32 if(i==len){ 33 return 0; 34 } 35 while(s[i]>='0'&&s[i]<='9'){ 36 i++; 37 } 38 if(i==len){ 39 return 1; 40 } 41 return 0; 42 } 43 }else if(s[i]=='E'){ 44 if(i==0){ 45 return 0; 46 } 47 i++; 48 if(s[i]=='+'||s[i]=='-'){ 49 i++; 50 } 51 if(i==len){ 52 return 0; 53 } 54 while(s[i]>='0'&&s[i]<='9'){ 55 i++; 56 } 57 if(i==len){ 58 return 1; 59 } 60 return 0; 61 } 62 return 0; 63 } 64 int t; 65 int main(){ 66 scanf("%d",&t); 67 getchar(); 68 while(t--){ 69 gets(s); 70 if(solve(s)){ 71 cout<<"YES"<<endl; 72 }else{ 73 cout<<"NO"<<endl; 74 } 75 } 76 return 0; 77 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~