zoukankan      html  css  js  c++  java
  • sicily 6275. 求平均分

    Description

    编程求解一个小班同学的测验平均分,得分为0到100之间的整数,由于可能有同学请假等原因,出席同学人数不定,输入以-1作为结束。求解平均数,保留1位小数输出。

    Input

    输入分数,直到输入-1结束。

    Output

    输出所有分数的平均值,保留1位小数

    就算对我这种菜鸟也是白痴题了……注意设成浮点型就OK。一次AC

    View Code
     1 #include<stdio.h>
     2 int main()
     3 {
     4     float n, total=0.0; 
     5     int counter=0;
     6     while( scanf("%f" , &n) && ( n + 1 >= 0.000001 ) )
     7     {
     8         total = total + n;
     9         counter++;
    10     }
    11     printf("%.1f\n", total/counter );
    12     return 0;
    13 }                                 
  • 相关阅读:
    day02-数据库操作
    day01-MySQL介绍
    3-socketserver
    1-多线程与多进程
    keyword模块
    math模块
    查看进程pid与ppid
    开启进程的两种方式
    进程理论
    进程
  • 原文地址:https://www.cnblogs.com/joyeecheung/p/2750458.html
Copyright © 2011-2022 走看看