Лера111222333
29.11.2021 23:33

Скласти програму для обчислення значення b=2a-a4+a28a+4

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
49583
27.12.2022 21:23
Romanf romanf отличник 2013-01-10t16: 13: 22+00: 00 1. подумать над алгоритмом 2. вот сам алгоритм: а. спросить у пользователя значения б. расчитать ответ в. выдать ответ на экран 3. написать код в паскале 4. исправить ошибки компиляции 5. протестировать, вводить разные числа 6. обнаружила, что если вводить числа наугад ответ получается отрицательным иногда 7. вставить код проверки введенных пользователем значений 8. убрать ошибки компиляции 9. протестировать 10. готово а вот и сама программа: program aerobus; uses crt; const totalplace = 160; var businessplaces, economyplaces: integer; businessprice, economyprice: real; totalcharge: real; a,b: integer; correctinput: boolean; begin clrscr; businessplaces: =totalplace div 4; economyplaces: = totalplace - businessplaces; writeln('business places count: ', businessplaces); writeln('economy places count: ', economyplaces); correctinput: =false; while not correctinput do begin write('please input business class ticket price: '); readln(businessprice); if(businessprice> 0) then begin correctinput: =true; end else begin writeln('the price should be a positive number, please try again'); end; end; economyprice: =businessprice/2; writeln('economy ticket price is: ', economyprice: 0: 2); correctinput: =false; while not correctinput do begin write('how many business tickets are left? : '); readln(a); if(a> =0) and (a< =businessplaces)then correctinput: =true; if(a< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(a> businessplaces) then begin writeln('please input a number which is less or equal to the tolal business place count, please try again'); end; end; correctinput: =false; while not correctinput do begin write('how many economy tickets are left? : '); readln(b); if(b> =0) and (b< =economyplaces)then correctinput: =true; if(b< 0) then begin writeln('please input a positive number or 0, please try again'); end; if(b> economyplaces) then begin writeln('please input a number which is less or equal to the tolal economy place count, please try again'); end; end; totalcharge: =(businessplaces-a)*businessprice; totalcharge: =totalcharge+(economyplaces-b)*economyprice; writeln('the total charge is: ', totalcharge: 0: 2); writeln; writeln('press enter to exit'); readln; end.
0,0(0 оценок)
Ответ:
123456qwe1234567
09.07.2020 22:35
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>

int main()  
  {
    SetConsoleCP(1251);      
    SetConsoleOutputCP(1251);  
 
int const n=3;
int mas[n][n];
int sum1, sum2;
bool magik;

for (int i=0; i<n; i++)
    for (int j=0; j<n; j++)
         {
           printf("mas[%d][%d] = ", i+1, j+1);
           scanf("%d",&mas[ i ][ j ]);
         }

printf("\nВведенная матрица:\n");
     for (int i=0; i<n; i++)
        {
             for (int j=0; j<n; j++)
                       {
                          printf("%d  ",mas[ i ][ j ]);
                       }
             printf("\n");
         }

sum1=0;
sum2=0;

for (int i = 0; i<n; i++)
     {
            sum1 += mas[ i ][ i ];
            sum2 += mas[ i ][ n-1-i ];
      }

printf("Сумма главной диагонали = %d\n", sum1);
printf("Сумма побочной диагонали = %d\n", sum2);

magik = true;
for (int i=0; i<n; i++)
    {
        if (sum1==sum2)
             {
                 sum2=0;
                 for (int j=0; j<n; j++)
                    {
                        sum2 += mas[ i ][ j ];
                     }
              } else  { magik=false; break; }
     }

if (magik==true)
     {
           for (int i=0; i<n; i++)    
               {
                   if (sum1==sum2)
                        {
                           sum2=0;
                           for (int j=0; j<n; j++)
                               {
                                   sum2 += mas[ j ][ i ];
                               }
                         }
                        else  { magik=false; break; }
                 }
       }

if (magik==true)
    printf("\nМатрица является магическим квадратом\n");  
else
    printf("\nМатрица не является магическим квадратом\n");

system("pause");
return 0;
}
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота