Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int c(int * b1,int * b2 , int n1, int n2){
  4.     int t=0;
  5.     for(int a=0;a<n1;a++){
  6.         t=t+b1[a];
  7. }
  8.     for (int m=0;m<n2;m++){
  9.         t=t+b2[m];
  10.         }
  11.     return t;
  12. }
  13.  
  14. int main() {
  15.     int n1;
  16.     int n2;
  17.    
  18.     cout<<"Введите n1: ";
  19.     cin>>n1;
  20.    
  21.     cout<<"Введите n2: ";
  22.     cin>>n2;
  23.     if(n1!=n2){
  24.         cout<<"ОШИБКА!!!"<<endl;
  25.         return 0;
  26.     }
  27.    
  28.    
  29.     int *b1 = new int[n1];
  30.     int *b2 = new int[n2];
  31.     cout<<"Введите b1: ";
  32.    
  33.     for(int i=0;i<n1;i++){
  34.         cout <<"Ввод "<< i << " числа: ";
  35.         cin>> b1[i];}
  36.    
  37.     cout<<"Введите b2: ";
  38.    
  39.     for(int i=0;i<n2;i++){
  40.         cout <<"Ввод "<< i << " числа: ";
  41.         cin>> b2[i];
  42.     }
  43.     cout<<endl<<"C: "<<c(b1,b2,n1,n2)<<endl;
  44.    
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement