So fun! It connects algorithm(regex) with real world usages!

So basically speaking, C:pointer syntax, #include\scanf\typedef; Java: import\public class syntax\try-catch syntax; Python: def syntax\special print syntax.

And BTW, if you are working on regex problems with Python, this is god-sent: http://pythex.org/

import re

import io
import sys
input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')

s = input_stream.readlines()
s = "\n".join(s)

pc = '([^/]\*[a-zA-Z]+\w*|typedef|#include|scanf)'
pj = '(import\s+|public\s+class|catch\s*[(].*?[)]|System\.)'
pp = '(print\s+[\w\"]+|[(][[][\"\s\w,]+[]][)]|def\s+[\w]+[(])'

mc = re.findall(pc, s)
mj = re.findall(pj, s)
mp = re.findall(pp, s)

bc = len(mc) > 0
bj = len(mj) > 0
bp = len(mp) > 0
if bc:
    print ("C")
if bj:
    print ("Java")
if bp:
    print ("Python")

 

相关文章:

  • 2022-02-07
  • 2021-12-14
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-08-07
  • 2021-09-28
猜你喜欢
  • 2022-12-23
  • 2021-11-26
  • 2021-11-10
  • 2021-09-30
  • 2021-10-22
  • 2021-08-08
  • 2021-11-18
相关资源
相似解决方案