练习题(八)

练习题(八)

时间限制: 1 Sec 内存限制: 128 MB
[命题人:171360205]
题目描述
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A * B.
输入
Each row contains an integer B(0<=B<=9), and A is identical to one . Process until the end of the file.
输出
For each test case, you should output two lines. The first line is “Case #:”, # means the number of the test case. The second line is the an equation “A * B = Sum”, Sum means the result of A * B. Note there are some spaces int the equation.
样例输入

1

样例输出

Case 1 :
one * zero = zero 
Case 2 :
one * one = one

翻译:
题目描述
我有一个非常简单的问题。 给定两个整数A和B,你的工作是计算A * B的和。
输入
每行包含一个整数B(0 <= B <= 9),A等于1。 处理直到文件结束。
输出
对于每个测试用例,您应输出两行。第一行是“Case#:”,#表示测试用例的编号。第二行是方程“A * B = Sum”,Sum表示A * B的结果。注意方程中有一些空格。
来源/分类
寒假练习赛
网址: http://47.112.31.182/problem.php?id=1072
题意:
本题就是让求从10到1n的输出用英语表示
思路:
可以先定义个二维数组把从0-9的英语单词存里面,然后用循环输出调用
代码:

#include <iostream>
#include <vector>
#include <string>
using namespace std;
vector<long long> v;
int main()
{
    vector<string> v;   //创建一个string类型的向量容器
    //尾部扩充元素v.push_back();
    v.push_back("zero");    //v[0]
    v.push_back("one");     //v[1]
    v.push_back("two");     //v[2]
    v.push_back("three");   //v[3]
    v.push_back("four");    //v[4]
    v.push_back("five");    //v[5]
    v.push_back("six");     //v[6]
    v.push_back("seven");   //v[7]
    v.push_back("eight");   //v[8]
    v.push_back("nine");    //v[9]
    int n;
    cin>>n;
    for(int i=0;i<=n;i++)   //按要求输出
    {
        cout<<"Case "<<i+1<<" :"<<endl;
        cout<<"one * "<<v[i]<<" = "<<v[i]<<endl;
    }
    return 0;
}

运行结果:
在这里插入图片描述
总结:
本题考英语和二维数组的使用。

猜你喜欢

转载自blog.csdn.net/qq_41657977/article/details/86708741