problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing718类 参考

AcWing 718. 实验 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 718. 实验

在文件 acwing.h698 行定义.

成员函数说明

◆ main()

int acwing::acwing718::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp1939 行定义.

1939 {
1940 unsigned short n;
1941 cin >> n;
1942 unsigned int c_count = 0;
1943 unsigned int r_count = 0;
1944 unsigned int f_count = 0;
1945 for(unsigned short i = 0; i < n; i++) {
1946 unsigned short a;
1947 char t;
1948 cin >> a >> t;
1949 switch(t) {
1950 case 'C':
1951 c_count += a;
1952 break;
1953 case 'R':
1954 r_count += a;
1955 break;
1956 case 'F':
1957 f_count += a;
1958 break;
1959 }
1960 }
1961 const unsigned int count = c_count + r_count + f_count;
1962 cout << setiosflags(ios::fixed) << setprecision(2) << "Total: " << count << " animals" << endl
1963 << "Total coneys: " << c_count << endl
1964 << "Total rats: " << r_count << endl
1965 << "Total frogs: " << f_count << endl
1966 << "Percentage of coneys: " << static_cast<double>(c_count) / static_cast<double>(count) * 100
1967 << " %" << endl
1968 << "Percentage of rats: " << static_cast<double>(r_count) / static_cast<double>(count) * 100
1969 << " %" << endl
1970 << "Percentage of frogs: " << static_cast<double>(f_count) / static_cast<double>(count) * 100
1971 << " %";
1972 return 0;
1973 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: