|
|
|
Работа с массивами
|
|||
|---|---|---|---|
|
#18+
Помогите пожалуйста начинающему программисту :( нужно исправить ошибку в программе: Уплотнить заданную матрицу, удаляя из неё нудевые столбцы и нулевые строки. #include <vcl.h> #include <iostream> #pragma hdrstop using namespace std; #pragma argsused int main(int argc, char* argv[]) { int n, **m, x, f,i,l,k,**m1,**m2,h; cout<<"Enter n\n"; cin>>n; m= new int*[n]; for (int i=0;i<n;i++) m =new int[n]; m1=new int*[n]; for (int i=0;i<n;i++) m1=new int[n]; m2=new int*[n]; for (int i=0;i<n;i++) m2=new int[n]; for (int f=0;f<n;f++) for(int x=0;x<n;x++){ cout<<"Enter elements "<<x<<f; cin>>m[f][x]; } l=0; for (f=0;f<n;f++) for (x=0;x<n;x++) if (m[f][x]!=0) { for (i=0;i<n;i++) m1[l]=m[f]; l++; break; } k=0; for (f=0;f<l;f++) for (x=0;x<n;x++) if (m[f][x]!=0) { for (i=0;i<l;i++) m2[k]=m1[x]; k++; break; } cout<<"\n\nMatrix:\n"; for(int f=0;f<n;f++) { for(int x=0;x<n;x++) cout<<m[f][x]<<'\t'; cout<<'\n'; } cout<<"\n\nMatrix:\n"; for(int f=0;f<k;f++) { for (int x=0;x<n;x++) cout<<m1[f][x]<<'\t'; cout<<'\n'; } cout<<"\n\nMatrix:\n"; for (int f=0;f<l;f++) { for (int x=0;x<n;x++) cout<<m2[f][x]<<'\t'; cout<<'\n'; } cin>>n; return 0; } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 30.05.2007, 16:29 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34561893&tid=2028781]: |
0ms |
get settings: |
10ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
174ms |
get topic data: |
10ms |
get forum data: |
3ms |
get page messages: |
28ms |
get tp. blocked users: |
1ms |
| others: | 239ms |
| total: | 487ms |

| 0 / 0 |
