cannot understand that c11 code , please help.

Revision en1, by IbrahimElmourchidi, 2019-02-05 09:49:41

hello Every one ! i solved this problem https://mirror.codeforces.com/problemset/problem/785/A using c11 and after i solved the problem i saw others submissions to check if some one have a better solution and so i found a submission i cannot understand can some one please help , this is it :


#include <stdio.h> int t, n; main() { scanf("%d\n", &n); while (n--) { char s[9]; gets(s); t += "4!8D6<"[*s%7]-48; // this the line i cannot understand } printf("%d\n", t); }

and that was my submission :

#include<stdio.h>
int main()
{
    int a,i=0,c=0;
    scanf("%d",&a);
    char b[13];
    gets(b);
    for(i=0;i<a;i++)
    {
        gets(b);
        c+=( b[0]=='I'?20:b[0]=='C'?6:b[0]=='O'?8:b[0]=='D'?12:4 );
    }
    printf("%d",c);
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English IbrahimElmourchidi 2019-02-05 09:49:41 853 Initial revision (published)