Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Новый участник


Сообщения: 15
Благодарности: 0

Профиль | Отправить PM | Цитировать


Изображения
Тип файла: jpg Безымянный.jpg
(132.3 Kb, 13 просмотров)
Тип файла: jpg Безымянный2.jpg
(65.9 Kb, 11 просмотров)

Задачу я решил. Я изменил код программы, взяв за основу, что ∆X = 1 и ∆Y = 1, т.о. кол-во строк = 11, а кол-во столбцов = 9. Вот код программы:

Код: Выделить весь код
#include <iostream>
 
using namespace std;
 
int main ()
{
        int i, j, n1, m1,k;
        float e=0.000001, max_pogr, d1, d2, next;
        int const n=11; //задаем количество строк в массиве
        int const m=9; //задаем количество столбцов в массиве
        float mas_U[n][m];
        d1=10.0/6.0;
        d2=5.0;
        n1=n-1;
        m1=m-1;
        cout<<"===Zadanie nulei===" << endl;
        cout<<"\n";
        for(i = 0; i < n; i ++) 
        {
              for(j = 0; j < m; j ++) 
              {
              mas_U[i][j] = 0;
              }
        }
        for(i = 0; i < n; i ++)
        {
            for(j = 0; j < m; j ++)
            {
              cout << mas_U[i][j] << "\t";
            }
              cout << endl;
        }
        
        cout<<"\n===Pervie granichnie usloviya===" << endl;
        cout<<"\n";
        for(i = 8; i < n; i++)
        {
        mas_U[i][0]=5;
        }
        for(i = 0; i < n; i ++)
        {
            for(j = 0; j < m; j ++)
            {
              cout << mas_U[i][j] << "\t";
            }
              cout << endl;
        }
        cout<<"\n===Vtorie granichnie usloviya===" << endl;
        cout<<"\n";        
        for(j = 1; j <= 7; j ++)
        {
              mas_U[0][j] = mas_U[0][j-1] + d1;
              }
        for(j = 7; j < m ; j ++)
                {
              mas_U[0][j] = mas_U[0][j-1] - d2;
              }
        for(i = 0; i < n; i ++)
        {
            for(j = 0; j < m; j ++)
            {
              cout << mas_U[i][j] << "\t";
            }
              cout << endl;
        }
        cout<<"\n===Podschet massiva===" << endl;
        cout<<"\n";         
        for(k=0;;k++)
        {
                max_pogr=0;
               for(i = 1; i < n1; i ++)
                       {
                            for(j = 1; j < m1; j ++)
                                  {
                                       next = (mas_U[i+1][j] + mas_U[i-1][j] + mas_U[i][j+1] + mas_U[i][j-1])/4;
                                       if((mas_U[i][j] - next) > max_pogr) max_pogr=(mas_U[i][j] - next);
                       else mas_U[i][j] = next;
                                  }
                        }
                        if(max_pogr<=e||k>=10000)break;
        }
        for(i = 0; i < n; i ++)
        {
              for(j = 0; j < m; j ++)
              printf("%7.4f\t",mas_U[i][j]);
              printf("\n\n");
        }
 
    system("pause");
    
        return 0;
}
Так же выкладываю результат и примерную блок-схему

Отправлено: 16:22, 07-06-2011 | #5