Need a code to write this programs

i want a program to write this:
program number 1:-

3 4 5 6
4 5 6 7
5 6 7 8
6 7 8 9

program number 2:-

3
4 5
5 6 7
6 7 8 9

program number 3:-

3 4 5 6
5 6 7
7 8
9


program number 4:-

6
6 7
6 7 8
6 7 8 9


program number 5:-

3 4 5 6
4 5 6
5 6
6


program number 6:-

3 4 5 6
4     7
5     8
6 7 8 9
OK, do you have any coding started? Hint; while loops and iterators.
this an example for a program i have made it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;
int main()
{
int n,a,min,i=1;
cout<<"Pleas enter N";
cin>>n;
cout<<"\nPlease enter number<<i<<": ";
cin>>a;
min=a;
for(i=2;i<=n;i++)
{
cout<<"\nPlease enter number<<i<<": ";
cin>>a;
if(a<min)
min=a;
}
cout<<"\nThe min is:"<<min<<endl;
return 0;
}
The first assignment can be done the following way

1
2
3
4
5
6
7
8
const int N = 4;
int initial_value = 3;

for ( int i = 0; i < N; i++ )
{
   iota_n( std:ostream_iterator<int>( std::cout, " " ), N, initial_value++ );
   std::cout << std::endl;
}:


So all you need is to write algorithm iota_n yourself.

The second assignment can be done the following way

1
2
3
4
5
6
7
8
const int N = 4;
int initial_value = 3;

for ( int i = 0; i < N; i++ )
{
   iota_n( std:ostream_iterator<int>( std::cout, " " ), i + 1, initial_value++ );
   std::cout << std::endl;
}:



The third assignment can look as

1
2
3
4
5
6
7
8
const int N = 4;
int initial_value = 3;

for ( int i = 0; i < N; i++ )
{
   iota_n( std:ostream_iterator<int>( std::cout, " " ), N - i, initial_value++ );
   std::cout << std::endl;
}:



The forth assignment can be done as

1
2
3
4
5
6
7
8
const int N = 4;
int initial_value = 6;

for ( int i = 0; i < N; i++ )
{
   iota_n( std:ostream_iterator<int>( std::cout, " " ), i + 1, initial_value );
   std::cout << std::endl;
}:

Last edited on
Thx can u explain the codes please
It is your professor who should explain you code. As for you you shall write code yourself.
i don't have a professor i'm learning by my self
Topic archived. No new replies allowed.