判断数据类型(10分)【 C语言基础 】

判断数据类型(10分)【 C语言基础 】

判断数据类型(10分)

Description

假设现在你要判断数据类型是否为int、long long、double,输入n个字符串,请你判断其代表的数据类型是什么,且输入的每个字符串保证是正数,且是这三种类型的一种。

Input

第一行一个整数n。(n<=10)

接下来n行每行一个字符串s。(|s|<=10)

Output

对于每个字符串s,输出“int”或“long long”或“double”。

Sample Input 1

代码语言:javascript复制3

12

9999999999

123.44Sample Output 1

代码语言:javascript复制int

long long

double解析:感谢QSH哈哈哈。

代码语言:javascript复制#include

#include

//#include

//#include

//#include

//#include

//#include

//#include

//#include

//#include

//#include

//using namespace std;

#define inf 0x3f3f3f3f

char a[100000];

int main()

{

int n,sb;

double x;

scanf("%d", &n);

while(n --){

scanf("%s",a);

int len = strlen(a);

int flag=0;

for(int i = 0; i < len; i ++){

if(a[i] == '.'){

flag = 1;break;

}

}

if(flag==1)printf("double\n");

else {

long long x = 0;

long long cnt = 1;

if(a[0] =='-') sb = 1;

else sb = 0;

for(int i = len - 1; i >= sb; i --){

x += cnt * (int)(a[i] -'0');

cnt *=10;

}

if(sb == 1) x *= -1;

if(x > 2147483647 || x < -2147483648)printf("long long\n");

else printf("int\n");

}

}

return 0;

}