+ 1
I need 1 22 333 4444 55555 answer
how please help me
4 ответов
+ 7
For that a nested loop will do the trick. The inner loop (b) outputs the number whilst the outer loop (a) controls what number will be output
#include <iostream>
using namespace std;
int main()
{
for (int a = 1; a <=5; a++) {
for(int b =1;b<=a;b++){
cout << a;
}
cout << " ";
}
return 0;
}
+ 7
#include<iostream>
using namespace std;
int main()
{
int num, c, k;
cout<<"Enter number of rows : ";
cin>>num;
cout<<"\n";
for ( c = 1 ; c <= num ; c++ ) {
for( k = 1 ; k <= c ; k++ )
{ cout<<c;
}
cout<<"\n"; } }
+ 7
Synchronized answers by 3 SoloLearners - now that's service 😎😎😎
+ 3
#include<iostream>
int main()
{
int a;
std::cin>>a;
for(int i=1;i<=a;i++)
{
for(int j=0;j<i;j++)
std::cout<<i;
std::cout<<" ";
}
}