Answers for "convert python to java online"

0

convert python to java online

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int m,ans=INT_MAX,I=-1,J=-1;
  cin>>m;
  vector<vector<int>> mat(m,vector<int>());
  cin.ignore();
  for(int i=0;i<m;i++)
  {
    string s;
    getline(cin,s);
    istringstream ss(s);
    while(ss)
    {
      string w;
      ss>>w;
      if(w=="") break;
      mat[i].push_back(stoi(w));
    }
  }
  int n=mat[0].size();
  vector<vector<int>> Ans1(m,vector<int>(n,1));
  vector<vector<int>> Ans2(m,vector<int>(n,1));
  vector<vector<int>> Ans3(m,vector<int>(n,1));
  vector<vector<int>> Ans4(m,vector<int>(n,1));
 
  for(int i=0;i<m-1;i++)
  for(int j=0;j<mat[i].size();j++)
  if(mat[i][j]==mat[i+1][j])
    Ans1[i+1][j]=Ans1[i][j]+1;
  
  for(int i=0;i<m;i++)
  for(int j=0;j<mat[i].size() -1;j++)
  if(mat[i][j]==mat[i][j+1])
    Ans2[i][j+1]=Ans2[i][j]+1;
  
  for(int i=0;i<m-1;i++)
  for(int j=0;j<mat[i].size()-1;j++)
  if(mat[i][j]==mat[i+1][j+1])
    Ans3[i+1][j+1]=Ans3[i][j]+1;
 
  for(int i=0;i<m-1;i++)
  for(int j=1;j<mat[i].size();j++)
  if(mat[i][j]==mat[i+1][j-1])
    Ans4[i+1][j-1]=Ans4[i][j]+1;
  
  for(int i=0;i<m;i++)
  for(int j=0;j<mat[i].size();j++)
  {
    if(Ans1[i][j]>=4 && ans>mat[i][j])
    {ans=mat[i][j];I=i;J=j;}
    if(Ans2[i][j]>=4 && ans>mat[i][j])
    {ans=mat[i][j];I=i;J=j;}
    if(Ans3[i][j]>=4 && ans>mat[i][j])
    {ans=mat[i][j];I=i;J=j;}
    if(Ans3[i][j]>=4 && ans>mat[i][j])
    {ans=mat[i][j];I=i;J=j;}
  }
  if(I==-1)cout<<-1;
  else cout<<ans<<endl;
  
}
Posted by: Guest on April-18-2021
0

convert python to java online

import check50
import check50_java

@check50.check()
def book_exists():
    """Book.java exists."""
    check50.exists("Book.java")

@check50.check(book_exists)
def book_compiles():
    """Book.java compiles."""
    check50_java.compile("Book.java")

@check50.check()
def press_exists():
    """Press.java exists."""
    check50.exists("Press.java")

@check50.check(press_exists)
def press_compiles():
    """Press.java compiles."""
    check50_java.compile("Press.java")

@check50.check()
def vm_exists():
    """VendingMachine.java exists."""
    check50.exists("VendingMachine.java")

@check50.check(vm_exists)
def vm_compiles():
    """VendingMachine.java compiles."""
    check50_java.compile("VendingMachine.java")
Posted by: Guest on April-29-2021

Code answers related to "convert python to java online"

Python Answers by Framework

Browse Popular Code Answers by Language