/ 科创班 /

记录详情

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 ≥1004ms ≥256.0 KiB
#2 Time Exceeded ≥1056ms ≥256.0 KiB
#3 Time Exceeded ≥1003ms ≥256.0 KiB
#4 Time Exceeded ≥1003ms ≥256.0 KiB
#5 Time Exceeded ≥1055ms ≥256.0 KiB
#6 Time Exceeded ≥1057ms ≥256.0 KiB
#7 Time Exceeded ≥1059ms ≥256.0 KiB
#8 Time Exceeded ≥1057ms ≥256.0 KiB
#9 Time Exceeded ≥1007ms ≥256.0 KiB
#10 Time Exceeded ≥1005ms ≥256.0 KiB

代码

#include <stdio.h>
#define MAX 1000
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 10:31:05
评测时间
2018-07-14 10:31:06
评测机
分数
0
总耗时
≥10310ms
峰值内存
≥256.0 KiB