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

洛谷 P1957 口算练习题 更多...

#include <luogu.h>

静态 Public 成员函数

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

详细描述

洛谷 P1957 口算练习题

在文件 luogu.h517 行定义.

成员函数说明

◆ main()

int luogu::P1957::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp1871 行定义.

1871 {
1872 int i;
1873 cin >> i;
1874 char op;
1875 for(int _ = 0; _ < i; _++) {
1876 int num1;
1877 int num2;
1878 string pos1;
1879 cin >> pos1;
1880 if(isalpha(pos1[0]) != 0) {
1881 op = pos1[0];
1882 cin >> num1 >> num2;
1883 } else {
1884 auto ss = stringstream();
1885 ss << pos1;
1886 ss >> num1;
1887 cin >> num2;
1888 }
1889 auto oss = ostringstream();
1890 switch(op) {
1891 case 'a':
1892 oss << num1 << '+' << num2 << '=' << num1 + num2;
1893 break;
1894 case 'b':
1895 oss << num1 << '-' << num2 << '=' << num1 - num2;
1896 break;
1897 case 'c':
1898 oss << num1 << '*' << num2 << '=' << num1 * num2;
1899 break;
1900 default:
1901 cerr << "Unknown Op:\t" << op;
1902 return 1;
1903 }
1904 string str = oss.str();
1905 cout << str << endl
1906 << str.length() << endl;
1907 }
1908 return 0;
1909 }

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


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