Multiply char by integer (c++)

后端 未结 6 678
甜味超标
甜味超标 2020-12-31 16:03

Is it possible to multiply a char by an int?

For example, I am trying to make a graph, with *\'s for each time a number occurs.

So something like, but this d

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 16:39

    //include iostream and string libraries
    
    using namespace std;
    
    int main()
    {
    
        for (int Count = 1; Count <= 10; Count++)
        {
            cout << string(Count, '+') << endl;
        }
    
        for (int Count = 10; Count >= 0; Count--)
        {
            cout << string(Count, '+') << endl;
        }
    
    
    return 0;
    

    }

提交回复
热议问题