/ 科创班 /

记录详情

Time Exceeded

/in/foo.c: In function 'main':
/in/foo.c:11:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
      if(c>='0'&&c<='9'||c>='a'&&c<='f'||c>='A'&&c<='F') t[i++]=c;             
         ~~~~~~^~~~~~~~
/in/foo.c:11:47: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
      if(c>='0'&&c<='9'||c>='a'&&c<='f'||c>='A'&&c<='F') t[i++]=c;             
                                         ~~~~~~^~~~~~~~
# 状态 耗时 内存占用
#1 Time Exceeded ≥10007ms ≥256.0 KiB
#2 Time Exceeded ≥10007ms ≥256.0 KiB
#3 Time Exceeded ≥10009ms ≥256.0 KiB
#4 Time Exceeded ≥10008ms ≥256.0 KiB
#5 Time Exceeded ≥10008ms ≥256.0 KiB
#6 Time Exceeded ≥10015ms ≥256.0 KiB
#7 Time Exceeded ≥10005ms ≥256.0 KiB
#8 Time Exceeded ≥10008ms ≥256.0 KiB
#9 Time Exceeded ≥10007ms ≥256.0 KiB
#10 Time Exceeded ≥10004ms ≥256.0 KiB

代码

#include <stdio.h>
#define MAX 10
int main()
{
int htoi(char s[]);

int c,i=0;
char t[MAX];

while((c=getchar())!='\n'&&i<MAX)
     if(c>='0'&&c<='9'||c>='a'&&c<='f'||c>='A'&&c<='F') t[i++]=c;             

t[i]='\0';
printf("%d",htoi(t));
return 0;
}


int htoi(char s[])
{
int i,n;
n=0;
for(i=0;s[i]!='\0';i++)
	{
	if(s[i]>='0'&&s[i]<='9')
    	n=n*16+s[i]-'0';
	if(s[i]>='a'&&s[i]<='f')
	    n=n*16+s[i]-'a'+10;
	if(s[i]>='A'&&s[i]<='F')
    	n=n*16+s[i]-'A'+10;
	}
return (n);
}
 

信息

递交者
类型
递交
题目
7.16十六进制转十进制
题目数据
下载
语言
C
递交时间
2018-07-14 17:08:50
评测时间
2018-07-14 17:08:50
评测机
分数
0
总耗时
≥100081ms
峰值内存
≥256.0 KiB