URI Online Judge Solution 1064 Positives and Average – Solution in C, C++, Java, Python and C#

URI Online Judge Solution URI Solution -Beginner

URI Online Judge Solution 1064 Positives and Average – Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1064 Positives and Average  | Beginner
URI Problem Link – https://www.urionlinejudge.com.br/judge/en/problems/view/1064

Problem Name: 1064 Positives and Average solution
Problem Number : URI – 1064 Positives and Average code
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1064 Positives and Average - Solution in C, C++, Java, Python and C#

URI 1064 Positives and Average  Code in C / URI 1002 solution in C:

/**
* Problem No: URI Online Judge Problem 1061
* Solution in C language
* Author: Maniruzzaman Akash
**/

#include <stdio.h>

int
main(){


float
n1,total = 0,average = 0;
int
totalNumber = 0;

for
(int i = 1; i <= 6; i++) {
scanf("%f", &n1);
if
(n1 > 0) {
totalNumber += 1;
total += n1;
}
}

average = total / totalNumber;

printf("%d valores positivosn", totalNumber);
printf("%.1fn",average);

}

Check URI 1064 problem solution in Live by Running it using the inputs

Input Sample Output Sample
7
-5
6
-3.4
4.6
12
4 valores positivos
7.4

Run Live URI 1064 in C:

URI 1064 Positives and Average  Code in C++ / URI 1002 solution in CPP:

/**
* Problem No: URI Online Judge Problem 1061
* Solution in C language
* Author: Maniruzzaman Akash
**/

#include <cstdio>

int
main()
{

double
n, ctr = 0;
double
tmp = 0;

for
(int i = 0; i < 6; ++i)
{

scanf("%lf", &n);
if
(n > 0){
tmp += n;
ctr++;
}
}


printf("%.0lf valores positivosn%.1lfn", ctr, tmp/ctr);

return
0;
}

URI 1064 Positives and Average  Code in java/ URI 1002 solution in Java:

import java.io.IOException;
import java.util.Scanner;

/**
* Problem: URI 1064 problem solution in java language
* Author: Maniruzzaman Akash
*/

public class
Main {

public static
void main(String[] args) throws IOException {


float
n1,total = 0,average = 0;
int
totalNumber = 0;
Scanner sc =new Scanner(System.in);
for
(int i = 1; i <= 6; i++) {
n1 =sc.nextFloat();
if
(n1 > 0) {
totalNumber += 1;
total += n1;
}
}

average = total / totalNumber;

System.out.print(totalNumber+" valores positivosn");
System.out.printf("%.1fn",average);

}

}

URI 1064 Positives and Average  Code in Python / URI 1002 solution in Python:

URI Solution 1064 Positives and Average  Code / URI 1002 solution in  C# (C Sharp):

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1064 Positives and Average  code in C, URI 1064 Positives and Average  code in C++, URI Positives and Average  solution in C, URI solution, URI 1064 Positives and Average  solution in C,URI 1064 Positives and Average  solution in C++-CPP, URI 1064 Positives and Average  solution in C# (C sharp),URI 1064 Positives and Average  solution in Java,URI 1064 Positives and Average  solution in Python,

Leave a Reply

Your email address will not be published.