Skip to content

Instantly share code, notes, and snippets.

@mamiwinsfall93
Created January 17, 2020 14:14
Show Gist options
  • Save mamiwinsfall93/e5267413f4d1d1cf82df8e1ac4e4cf3e to your computer and use it in GitHub Desktop.
Save mamiwinsfall93/e5267413f4d1d1cf82df8e1ac4e4cf3e to your computer and use it in GitHub Desktop.
/*
Positive number
Use the keyboard to enter three integers. Display the number of positive numbers in the original set.
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int[] a = new int[3];
a[0] = sc.nextInt();
a[1] = sc.nextInt();
a[2] = sc.nextInt();
int count = 0;
for (int i = 0; i < 3; i++) {
if (a[i] > 0) {
count ++;
}
}
System.out.println(count);
}
}
@FaikYY
Copy link

FaikYY commented Jun 8, 2020

Clean, simple but quite enough to solve the problem. Thanks for sharing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment