Überprüfen Sie ungerade Zahlen Numpy
# Input
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
arr[arr % 2 == 1]
#> array([1, 3, 5, 7, 9])
Ferry_Morris
# Input
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
arr[arr % 2 == 1]
#> array([1, 3, 5, 7, 9])
#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"enter the number\n ";
cin>>x;
if(x%2==0)
{
cout<<"this number is even \n";
}
else
{
cout<<"this number is odd \n";
}
return 0;
}
public class EvenOdd{
public static void evenOddValue(int value) {
if(value % 2 == 0){
System.out.println("The given value is even: " + value);
}
else{
System.out.println("The given value is odd: " + value);
}
}
public static void main(String [] args) {
int num = 25;
EvenOdd obj = new EvenOdd();
obj.evenOddValue(num);
}
}
<?php
$check1 = 3534656;
$check2 = 3254577;
if($check1%2 == 0) {
echo "$check1 is Even number <br/>";
} else {
echo "$check1 is Odd number <br/>";
}
if($check2%2 == 0) {
echo "$check2 is Even number";
} else {
echo "$check2 is Odd number";
}
?>
Numbers -- odd & even
Write a method which can identifies given number is even or odd
EX:
identify(5) -> "Odd"
identify(6) -> "Even"
Solution :
public static String identifyOddEven( int n ) {
return n%2==0 ? "Even" : "odd" ;
}