Skip to content

Commit 1a181ce

Browse files
committed
GeeksForGeeks Excel Sheet Problem
An String Problem.
1 parent d75efc9 commit 1a181ce

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

GEEKSFORGEEKS/Geeks_Excel_Sheet.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//GeeksForGeeks Problem : Excel Sheet | Part -2 (Easy)
2+
//Author : Piyush
3+
#include<stdio.h>
4+
#include<string.h>
5+
#include<math.h>
6+
int main()
7+
{
8+
int t,sum,i,j,l,k;
9+
char str[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'},str1[10];
10+
scanf("%d",&t);
11+
while(t--)
12+
{
13+
sum=0;
14+
scanf("%s",str1);
15+
l=strlen(str1);
16+
k=0;
17+
for(i=l-1;i>=0;i--)
18+
{
19+
for(j=0;j<26;j++)
20+
{
21+
if(str1[i] == str[j])
22+
{
23+
sum+=(j+1)*pow(26,k);
24+
break;
25+
}
26+
}
27+
k++;
28+
}
29+
printf("%d\n",sum);
30+
}
31+
return 0;
32+
}

0 commit comments

Comments
 (0)