python to java converter online code example

Example 1: python to java converter online

def neighbour(map, node, m, n):
    calc_neighbour= [-8, -7, 1, 9, 8, 7, -1, -9]
    neighbour=[]
    for i in range(0,len(map[node])):
        a = map[node][i]
        if(a==1):
            x= node+calc_neighbour[i]+1
            if(x>0 and x<=m*n):
                neighbour.append(x)
    return neighbour

Example 2: python to java converter online

def average():
  sum=0
  n=int(input())
  p=int(input())
  for i in range(n,(n*p+1),n):
    sum=sum+i
  return int(sum/p)
print(average())

Example 3: python to java converter online

def average():
  sum=0
  n=int(input())
  p=int(input())
  for i in range(n,(n*p+1),n):
    sum=sum+i
  return int(sum/p)
print(average())

Example 4: python to java converter online

k, m, a, b = int(input()), int(input()), int(input()), int(input())
res = 0
for i in range(a, b+1):
    if i % k == 0:
        res += 1
    if i % m == 0:
        res -= 1
print(res)

Example 5: python to java converter online

switch(escalaParaConverter){
            case 'C':
                if(this.getTemp().getEscala()=='K') this.kelvinParaCelsius();
                else if(this.getTemp().getEscala()=='F') this.fahrenheitParaCelsius();
                break;
            case 'K':
                if(this.getTemp().getEscala()=='C') this.celsiusParaKelvin();
                else if(this.getTemp().getEscala()=='F') this.fahrenheitParaKelvin();
                break;
            case 'F':
                if(this.getTemp().getEscala()=='C') this.celsiusParaFahrenheit();
                else if(this.getTemp().getEscala()=='K') this.kelvinParaFahrenheit();
                break;
        }

Example 6: python to java converter online

#!/usr/bin/python

"""mapper.py"""

from __future__ import print_function
import sys

for line in sys.stdin:
    number = int(line)
    print(number, '1')

Tags:

Misc Example