Да се отпечатат с числа следните фигури (само че не до 3, а до произволно N):
- 1 2 3
1 2 3
1 2 3 - 1 1 1
2 2 2
3 3 3 - 3 3 3
2 2 2
1 1 1 - 1 2 3
1 2
1 - 1 2 3 4
4 3 2 1
1 2 3 4
4 3 2 1 - 1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
Да се отпечатат с числа следните фигури (само че не до 3, а до произволно N):
[c] за С++ програми [/c]
[pascal] за паскал [/pascal]

за Къде се намира точка
за Вмъкване и изтриване на елемент *
за Позицията на X




за Броят на максималните елементи




за Броят на максималните елементи
за Пари за закуска




за Ученици с дадена оценка




за По-големи от средното| П | В | С | Ч | П | С | Н |
|---|---|---|---|---|---|---|
| « февр. | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
//Poduslovie 1 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=1;i<=n;i++){ cout<<endl; for(int j=1;j<=n;j++) cout<<j<<" "; } cout<<endl;//Poduslovie 2 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=1;i<=n;i++){ cout<<endl; for(int j=1;j<=n;j++) cout<<i<<" "; } cout<<endl;//Poduslovie 3 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=n;i>=1;i--){ cout<<endl; for(int j=n;j>=1;j--) cout<<i<<" "; } cout<<endl;//Poduslovie 4 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=1;n!=0;i++){ cout<<endl; for(int j=1;j<=n;j++) cout<<j<<" "; n--; } cout<<endl;Много добре си се сетил да намаляваш n! Но в такъв случай защо ти е въобще променливата i?
//Poduslovie 5 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=1;i<=n;i++){ cout<<endl; if(i%2==1){ for(int j=1;j<=n;j++) cout<<j<<" "; } else{ for(int j=n;j>=1;j--) cout<<j<<" "; } } cout<<endl;//Poduslovie 6 int n; cout<<"Vavedete chisloto n: "; cin>>n; for(int i=1;i<=n;i++){ cout<<endl; if(i%2==1){ for(int j=1;j<=n;j++) cout<<j%2<<" "; } else{ for(int j=n-1;j>=0;j--) cout<<j%2<<" "; } } cout<<endl;Браво!
#include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) { int n; cout<<"Vavedi chislo: "; cin>>n; //Първа задача: cout<<endl; cout<<"1. "; for(int i=1;i<=n;i++){ for(int k=1;k<=n;k++) cout<<k<<" "; for(int k=2;k<=n;k++) cout<<setw(4); cout<<endl; } cout<<endl; cout<<endl; //Втора задача: cout<<setw(0); cout<<"2. "; for(int i=1;i<=n;i++){ for(int k=1;k<=n;k++) cout<<i<<" "; for(int i=2;i<=n;i++) cout<<setw(4); cout<<endl; } cout<<endl; cout<<endl; //Трета задача: cout<<setw(0); cout<<"3. "; for(int i=n;i>=1;i--){ for(int k=n;k>=1;k--) cout<<i<<" "; for(int i=n-1;i>=1;i--) cout<<setw(4); cout<<endl; } cout<<endl; cout<<endl; //Четвърта задача: cout<<setw(0); cout<<"4. "; for(int i=n;i>=1;i--){ for(int k=1;k<=i;k++) cout<<k<<" "; for(int i=n;i>=2;i--) cout<<setw(4); cout<<endl; } cout<<endl; cout<<endl; //Пета задача: cout<<setw(0); cout<<"5. "; for(int i=1;i<=n;i++){ if(i%2==1){ for(int k=1;k<=n;k++) cout<<k<<" "; for(int i=2;i<=n;i++) cout<<setw(4); cout<<endl; } else{ for(int k=n;k>=1;k--) cout<<k<<" "; for(int i=2;i<=n;i++) cout<<setw(4); cout<<endl; } } cout<<endl; cout<<endl; //Шеста задача: cout<<setw(0); cout<<"6. "; for(int i=1;i<=n;i++){ if(i%2==1){ for(int k=1;k<=n;k++) cout<<k%2<<" "; for(int i=2;i<=n;i++) cout<<setw(4); } else { for(int k=2;k<=n+1;k++) cout<<k%2<<" "; for(int i=2;i<=n;i++) cout<<setw(4); } cout<<endl; } cout<<endl; system("pause"); return 0; }Брей че красиво (и вярно, разбира се) :-) Нямаш обаче нужда от циклите за setw(4).