| Soorena (15) | |
| sorry,i cant understand your problem , can explain clear than? | |
|
|
|
| Atyab (2) | |
|
If you exclude the loops that are used to print array, then this program does the task in 2 loop, 1 outer while loop and 1 inner for loop ... #include <iostream> using namespace std; //Function Definition void display_arr(int arr[],int size) { for(int i=0;i<size;i++) cout << arr[i] << " "; for(int i=size-2;i>=0;i--) cout << arr[i] << " "; } int main() { //Declaration int n=4, t=n-1, *arr=new int[n]; //Initialization for(int i=0;i<n;i++) arr[i]=1; //Borders START for(int i=0;i<(n*2)-1;i++) cout << 1 << " "; cout << endl; while(t!=0) { //Incrementing Elements for(int i=n-t;i<n;i++) { arr[i]++; } //Displaying Array display_arr(arr,n); cout << endl; t--; } fflush(stdin); cin.ignore(); return 0; } | |
|
|
|
| Soorena (15) | |||
best code is here,if you dont think so , please tell me...
| |||
|
|
|||