我想制作打印此类输出的通用代码,意味着用户可以输入任何值+整数.
*
* *
* * *
* * * *
* * * * *
Run Code Online (Sandbox Code Playgroud)
为5
和
*
* *
* * *
Run Code Online (Sandbox Code Playgroud)
为3.
在这里我做了什么.但它打印出正确的三角形.任何帮助.提前致谢.
#include <iostream>
using namespace std;
int main()
{
int val;
cout << "Enter the number: ";
cin >> val;
int t = val;
int x = val;
for(int r = 1; r <= val; r++)
{
for(int c = 1; c <=t ; c++)
{
if(c < x)
{
cout << ' ';
} …Run Code Online (Sandbox Code Playgroud) 我只是坚持错误" 线程中的异常"主"java.lang.NullPointerException "请告诉我我提交的错误,解决方案.它是一个简单的数组.我如何从这个数组访问方法setAge(int).
Person arr[] = new Person[2];
arr[0].setAge(20);
Run Code Online (Sandbox Code Playgroud)
谢谢.