Jump to content

პროგრამა დამასრულებინეთ


Recommended Posts

პროგრამამ უნდა შეკრიბოს მასივის ლუწინდექსიანი წევრები და გამოიტანოს ჯამი ფუნქციის მეშვეობით,მე რაც შევძელი ეს არის,დამეხმარეთ

#include<iostream.h>

#include<stdlib.h>

#define n 5

int luwebi(int);

main ()

{

int luwebi();

system("pause");

return 0;

}

int luwebi(int)

{

int i,a[n],s;

for(i=0;i<n;i++){

cout<<"sheitanet ricxvi\n";

cin>>a[n];

}

for(i=0;i<n;i++){

if(i%2==0){

s=a[0]+a[n];

}

cout<<s;

}

return s;

}

Link to comment
Share on other sites

პროგერების ამბავში გვიჭირს ცოტა.

მაგრამ თუ შეუძლია ვინმეს დახმარება უყურადღებოდ არ დაგტოვებს ;)

Link to comment
Share on other sites

gamarjoba.

Chven programirebashi ar verkvevit,am forumze mag tipis shekitxvaze pasuxs ver miigeb,mara tu aparaturuli problema gaqvs aqa vart

Link to comment
Share on other sites

ვებ პროგრამირება რომ იყოს დაგეხმარებოდი, მაგრამ ეგ ენა ნამდვილად არ ვიცი.

Link to comment
Share on other sites



void luw()

{

	for(i=0; i<n; i+=2) sum+=a[i];

}

უბრალოდ ციკლში ბიჯი გაზარდე ორით (i+=2) :)
#include <iostream>

using namespace std;


int i,sum=0,a[5];


void luw()

{

	for(i=0; i<5; i+=2) sum+=a[i];

}


int main()

{

	for(i=0; i<5; i++) cin>>a[i];


	luw();

	cout<<sum;


	return 0;

}

Link to comment
Share on other sites

#include <iostream>#include <vector> using namespace std;Int main () {int a;vector <int> V;while (cin >>a)V.push_back(a);int sum = 0 ;for (int i=0 ; i < V.size() ; i++ )if ( V % 2 == 0 )sum += V;cout << "sum = " <<sum <<endl;sysem("pause");return 0;}

ასეა და რავიცი :D ძმაკაცმა გამიკეთა ოღონდ ეს ვექტორზეა.

Link to comment
Share on other sites

#include <iostream>#include <vector> using namespace std;Int main () {int a;vector <int> V;while (cin >>a)V.push_back(a);int sum = 0 ;for (int i=0 ; i < V.size() ; i++ )if ( V % 2 == 0 )sum += V;cout << "sum = " <<sum <<endl;sysem("pause");return 0;}

ასეა და რავიცი :D ძმაკაცმა გამიკეთა ოღონდ ეს ვექტორზეა.

V % 2 == 0

მანდ ლუწ ინდექსიანი კი არა ლუწი მნიშვნელობის ელემენტები იკრიბება, მასივიც ხო იგივე ვექტორია :) vector-ის გამოყენებით კიდევ უფრო მარტივია :) ფუქნცია რომ უწერია თორე ფუნქციაც რა საჭიროა :)

Link to comment
Share on other sites

პროგრამამ უნდა შეკრიბოს მასივის ლუწინდექსიანი წევრები და გამოიტანოს ჯამი ფუნქციის მეშვეობით,მე რაც შევძელი ეს არის,დამეხმარეთ

#include <iostream>

#include <vector>

using namespace std;

int main () {

int a;

vector <int> V ;

while (cin >> a )

V.push_back(a);

int sum = ;

for (int i= ; i < V.size() ; i++)

if (V % 2 == 0 )

sum += V ;

cout << " Luwi elementebis jami aris " <<sum <<endl;

system("pause");

return 0;

}

მე ასე დავწერდი ამ პროგრამას ვექტორებისთვის .

)
Link to comment
Share on other sites

პროგერების ამბავში გვიჭირს ცოტა.

მაგრამ თუ შეუძლია ვინმეს დახმარება უყურადღებოდ არ დაგტოვებს ;)

gamarjoba.

Chven programirebashi ar verkvevit,am forumze mag tipis shekitxvaze pasuxs ver miigeb,mara tu aparaturuli problema gaqvs aqa vart

not so fast :)

მასივები არ მისაწვლია კარგად :|

ჩემთვის მოცემული დავალება კი გამოვიდა,მარა ამას ვერ ვასწორებ რაღაც :( დაწერლ ვარიანტებს ვნახავ ახლა,მალდობა გამომაურებისთვის :)

Link to comment
Share on other sites

     for(i=0; i<5; i++)

	{

		cin>>n;

		if(i%2==0) sum+=n;

	}


	cout<<sum;

ლუწ ინდექსიანიების ჯამი :) თუ ლუწების ჯამია საჭირო მაშინ n%2==0 და ესაა :chojinfc:

Link to comment
Share on other sites

     for(i=0; i<5; i++)

	{

		cin>>n;

		if(i%2==0) sum+=n;

	}


	cout<<sum;

ლუწ ინდექსიანიების ჯამი :) თუ ლუწების ჯამია საჭირო მაშინ n%2==0 და ესაა :chojinfc:

:thumbsup:

მე ნახვას ვერ ვასწრებ ,და თვითონ შემოიხედავს მერე :)

Link to comment
Share on other sites

დავხურო?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.