Skip to main content

URI Online Judge problem 1064 solved

URI Online Judge | 1064

Positives and Average

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 6 values that can be floating point numbers. After, print how many of them were positive. In the next line, print the average of all positive values typed, with one digit after the decimal point.

Input

The input consist in 6 numbers that can be integer or floating point values. At least one number will be positive.

Output

The first output value is the amount of positive numbers. The next line should show the average of the positive values ​typed.
Input SampleOutput Sample
7
-5
6
-3.4
4.6
12
4 valores positivos
7.4                                    


                                  
#include<stdio.h>
int main()
{
    int i,pos=0,neg=0;
    double avr,a,b=0;
    for(i=1;i<=6;i++)
    {
        scanf("%lf",&a);
        if(a>0){
            b+=a;
            pos++;
        }
        avr=b/pos;
    }
    printf("%d valores positivos\n",pos);

    printf("%.1lf\n",avr);

    return 0;
}

Comments

Popular posts from this blog

**Competitive Programming এর জন্য কি কি শিখতে হবে...**

link: https://github.com/me-shaon/bangla-programming-resources -------------------------------------------------------------------------------------------------------------------------- এলগোরিদম ব্যাসিক বিগ "O" নোটেশন  -  শাফায়েত আশরাফ কমপ্লেক্সিটি ক্লাস(P-NP, টুরিং মেশিন ইত্যাদি)  -  শাফায়েত আশরাফ ডাটা স্ট্রাকচার অ্যাারে (Array) অ্যারে ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ অ্যারে কমপ্রেশন/ম্যাপিং  -  শাফায়েত আশরাফ লিংকড লিস্ট (Linked List) লিংকড লিস্ট  -  শাফায়েত আশরাফ লিংকড লিস্ট ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ লিংকড লিস্ট  -  অনিন্দ্য পাল লিংকড লিস্ট – সি  -  মুনতাসির ওয়াহেদ ডাটা স্ট্রাকচার ও লিংকড লিস্ট  -  আলাভোলা কোডিং লিংকড লিস্ট  -  আলাভোলা ডাবলি লিংকড লিস্ট  -  মুনতাসির ওয়াহেদ স্ট্যাক (Stack) স্ট্যাক  -  শাফায়েত আশরাফ স্ট্যাক ব্যাসিক অপারেশন  -  হাসান আবদুল্লাহ স্ট্যাক বেসিক ডাটা স্ট্রাকচার  -  আহম...

codeforce problemset 758A solved

A. Holiday Of Equality time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. Totally in Berland there are  n  citizens, the welfare of each of them is estimated as the integer in  a i  burles (burle is the currency in Berland). You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them. Input The first line contains the integer  n  ( 1 ≤  n  ≤ 100 ) — the number of citizens in the kingdom. The second line contains  n  integers  a 1 ,  a 2 , ...,  a n , where  a i  ( 0 ≤  a i  ≤ 10 6 ) — the welfare of the  i -th citizen. Output In the only li...

700 problems to understand you complete algorithmic programming.

700 problems to understand you complete algorithmic programming. 1. Segment Tree: To Read : http://www.topcoder.com/tc?d1=tutorials&d2=lowestCommonAncestor&module=Static http://ronzii.wordpress.com/2011/07/08/segment-tree-tutorial/ http://se7so.blogspot.in/2012/12/segment-trees-and-lazy-propagation.html http://olympiad.cs.uct.ac.za/presentations/camp3_2007/interval_trees.pdf http://codeforces.com/blog/entry/6281 http://apps.topcoder.com/forums/?module=Thread&threadID=651820&start=0&mc=2#1146133 http://www.algorithmist.com/index.php/Segmented_Trees http://letuskode.blogspot.in/2013/01/segtrees.html http://wcipeg.com/wiki/Heavy-light_decomposition http://discuss.codechef.com/questions/5960/rnestescape-from-the-mines http://ideone.com/dPS5N  (Heavy Light implementation). https://sites.google.com/site/indy256/algo/heavy_light  (Heavy Light implementation). Problems: http://www.spoj.com/problems/GSS1 http://www.spoj.com/problems/GSS2 http://www.spoj.com...