field

We have 2 fields - 6 numbers. Summing up homotopy elements and stores them in the third field.

2 5------> 7
3 5------>8
4 11------>15

what are homotopy elements?
the number which are in the same position
Could you show the part of your code that you have problems with?
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
32
33
34
35
#include <iostream>	// vhodno-izhodni ukazi
#include <stdlib.h> //standardni ukazi
#include <string> // za la?je delo z nizi, veljavno le v C++ in ne v C#
#include <iostream>
using namespace std;
 
int main()
{
    int polje1[6];
    int polje2[6];
    int polje_vsot[6];
 
    cout<<"Vnesite elemente prvega polja: "<<endl;
     
    for(int i=0; i<6; i++)
        cin>>polje1[i];
 
    cout<<"Vnesite elemente drugega polja: "<<endl;
 
    for(int i=0; i<6; i++)
    cin>>polje2[i];
 
 
    short rezultat;
    //Sestevanje istoležnih elementov v obeh poljih
    for(int i=0; i<6; i++)
    {
        rezultat = polje1[i] + polje2[i];
        
    }
    
    cout<<"REZILTAT"<<rezultat<<endl;
    system("pause");
    return 0;
}




how to display the result in reverse order
Why is resultat a short? You do store a sum of ints to it.

The loop on lines 26-30 could be replaced with rezultat = polje1[5] + polje2[5]; because that is what you effectively do in it.

You don't use polje_vsot anywhere.

Reverse? How about for (int i=5; 0<=i; --i). It's crude, but could suffice.
example.

1 2 result 3
2 3 5
3 11 14
4 1 5
5 1 6
6 12 18


result on display - 18 -6-5-14-5-3 (reverse order)
THIS IS RESULT.
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
   
#include <cstdlib>
#include <iostream>


using namespace std;
 
int main()
{
    int polje1[6];
    int polje2[6];
    int polje_vsot[6];
    int rezultat;
 
    cout<<"Vnesite elemente prvega polja: "<<endl;
     
    for(int i=0; i<6; i++)
        cin>>polje1[i];
 
    cout<<"Vnesite elemente drugega polja: "<<endl;
 
    for(int i=0; i<6; i++)
    cin>>polje2[i];
    
 
    //Sestevanje istoležnih elementov v obeh poljih
    for(int i=0; i<6; i++)
    {
        rezultat= polje1[i] + polje2[i];
        polje_vsot[i] = rezultat;
    }
 
   
   
   for(int i=6; 0<i; )
  {
    i=i-1;
    cout<<"resitev izpisane  v obratnem vrstnem redu"<<polje_vsot[i]<<endl;  
     
  }
   
    system("pause");
    return 0;
}

 
 


which field have a large sum?
how is code ?

Topic archived. No new replies allowed.