-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAKVDEM02.cpp
More file actions
67 lines (66 loc) · 991 Bytes
/
AKVDEM02.cpp
File metadata and controls
67 lines (66 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#define LL long long
using namespace std;
char *strrev(char *str)
{
char *p1, *p2;
if (! str || ! *str)
return str;
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
{
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return str;
}
int main()
{
int t;
LL fact[16];
fact[0]=1;
for(int i=1;i<=15;i++)
{
fact[i]=fact[i-1]*i;
}
scanf("%d ",&t);
while(t--)
{
string s;
cin>>s;
if(s=="Integer")
{
int num;
scanf("%d",&num);
printf("%lld\n",fact[num]);
}
else if(s=="Long")
{
LL l_num;
int sum=0;
scanf("%lld",&l_num);
while(l_num)
{
sum+=l_num%10;
l_num/=10;
}
printf("%d\n",sum);
}
else if(s=="String")
{
char s1[200];
scanf("%s",s1);
printf("%s\n",strrev(s1));
}
else
{
double f;
scanf("%lf",&f);
printf("%d\n",(int)f);
}
}
return 0;
}