java to python

#include<stdio.h>
int stack[10000000]={0};
int top=-1;
 
void push(int c)
{
    stack[++top]=c;
}
 
void pop()
{
    stack[top--]=0;
}
 
int main()
{
    int N,max=0;
    int order=1;
    scanf("%d",&N);
    int arr[N];
    for(int i=0;i<N;i++)
    {
        scanf("%d",&arr[i]);
        if(max<arr[i])
        max=arr[i];
    }
    
    for(int i=0;i<N;i++)
    {
        while(top!=-1 && stack[top]==order)
        {
            order++;
            pop();
        }
        if(arr[i]==order)
        {
            order++;
          
        }
        else
        push(arr[i]);
        
    }
      while(top!=-1 && stack[top]==order)
        {
            order++;
            pop();
        }
    
    if(order==max+1)
    printf("Happy");
    else
    printf("Sad");
    
    
}

3.67
3
EngFan 70 points

                                    package myproject;

import java.util.Scanner;

public class SEGP {

	public static void main(String[] args) {
		int n,j=0;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int a[]=new int[n+1]; 
		int b[] = new int[n];
		for(int i=0;i&lt;n;i++)
			a[i]=sc.nextInt();

		for(int i=0;i&lt;n;i++)
		{
			if(a[i]&lt;a[i+1])
			{
				b[j]= a[i+1];
				j++;
			}
		}
	    	b[j]=a[n-1];
		for(int i=0;i&lt;j+1;i++)
			System.out.print(b[i]+&quot; &quot;);
        sc.close();
	}

}

3.67 (3 Votes)
0
4
1
Dan Aloni 105 points

                                    import javax.swing.*;

public class Exe4{
	//metodo para calculo de Potencia
public static int exp(int n1,int n2)   
{
	int i=0, total=0;
	
	while(i&lt;=n2)
	{
			total = n1*n2;	
			i++;
	}
	return total; 
    
}
  
       
	//metodo principal
	public static void main(String args[]){
		//Declara&ccedil;&atilde;o de Vari&aacute;veis
		int num1, num2;
		
		//Entrada de Dados do Usu&aacute;rio
		num1 = Integer.parseInt(JOptionPane.showInputDialog(&quot;Digite um n&uacute;mero&quot;));  
		num2 = Integer.parseInt(JOptionPane.showInputDialog(&quot;Digite outro n&uacute;mero&quot;));  
		
		//Exibi&ccedil;&atilde;o dos dados
		
		JOptionPane.showMessageDialog(null, exp(num1,num2));
		
	}
	
}

4 (1 Votes)
0
4
10

                                    hrs = input(&quot;Enter Hours:&quot;)
h = float(hrs)
rph=float(input(&quot;Enter rate per hours:&quot;))
if hrs&gt;40:
    print (40*rph +(h-40)*rph*1.5)
else:
    print(h*rph)

4 (10 Votes)
0
0
0
Hbaromega 100 points

                                    package myproject;

import java.util.Scanner;

public class SEGP {

	public static void main(String[] args) {
		int n,j=0;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int a[]=new int[n+1]; 
		int b[] = new int[n];
		for(int i=0;i&lt;n;i++)
			a[i]=sc.nextInt();

		for(int i=0;i&lt;n;i++)
		{
			if(a[i]&lt;a[i+1])
			{
				b[j]= a[i+1];
				j++;
			}
		}
	    	b[j]=a[n-1];
		for(int i=0;i&lt;j+1;i++)
			System.out.print(b[i]+&quot; &quot;);
        sc.close();
	}

}

0
0
5
1
Ercbrk 100 points

                                    import javax.swing.*;

public class Exe4{
	//metodo para calculo de Potencia
public static int exp(int n1,int n2)   
{
	int i=0, total=0;
	
	while(i&lt;=n2)
	{
			total = n1*n2;	
			i++;
	}
	return total; 
    
}
  
       
	//metodo principal
	public static void main(String args[]){
		//Declara&ccedil;&atilde;o de Vari&aacute;veis
		int num1, num2;
		
		//Entrada de Dados do Usu&aacute;rio
		num1 = Integer.parseInt(JOptionPane.showInputDialog(&quot;Digite um n&uacute;mero&quot;));  
		num2 = Integer.parseInt(JOptionPane.showInputDialog(&quot;Digite outro n&uacute;mero&quot;));  
		
		//Exibi&ccedil;&atilde;o dos dados
		
		JOptionPane.showMessageDialog(null, exp(num1,num2));
		
	}
	
}

5 (1 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source