MCsanchez Posted January 16, 2012 Share Posted January 16, 2012 პროგრამამ უნდა შეკრიბოს მასივის ლუწინდექსიანი წევრები და გამოიტანოს ჯამი ფუნქციის მეშვეობით,მე რაც შევძელი ეს არის,დამეხმარეთ #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 More sharing options...
საბა Posted January 16, 2012 Share Posted January 16, 2012 პროგერების ამბავში გვიჭირს ცოტა. მაგრამ თუ შეუძლია ვინმეს დახმარება უყურადღებოდ არ დაგტოვებს ;) Link to comment Share on other sites More sharing options...
zV1 Posted January 16, 2012 Share Posted January 16, 2012 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 More sharing options...
Guest Posted January 16, 2012 Share Posted January 16, 2012 ვებ პროგრამირება რომ იყოს დაგეხმარებოდი, მაგრამ ეგ ენა ნამდვილად არ ვიცი. Link to comment Share on other sites More sharing options...
sys32 Posted January 16, 2012 Share Posted January 16, 2012 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 More sharing options...
ბექა Posted January 16, 2012 Share Posted January 16, 2012 #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;} ასეა და რავიცი ძმაკაცმა გამიკეთა ოღონდ ეს ვექტორზეა. Link to comment Share on other sites More sharing options...
sys32 Posted January 16, 2012 Share Posted January 16, 2012 #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;} ასეა და რავიცი ძმაკაცმა გამიკეთა ოღონდ ეს ვექტორზეა. V % 2 == 0 მანდ ლუწ ინდექსიანი კი არა ლუწი მნიშვნელობის ელემენტები იკრიბება, მასივიც ხო იგივე ვექტორია vector-ის გამოყენებით კიდევ უფრო მარტივია ფუქნცია რომ უწერია თორე ფუნქციაც რა საჭიროა Link to comment Share on other sites More sharing options...
Giga.Chalauri Posted January 16, 2012 Share Posted January 16, 2012 პროგრამამ უნდა შეკრიბოს მასივის ლუწინდექსიანი წევრები და გამოიტანოს ჯამი ფუნქციის მეშვეობით,მე რაც შევძელი ეს არის,დამეხმარეთ #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 More sharing options...
L1nux Posted January 16, 2012 Share Posted January 16, 2012 პროგერების ამბავში გვიჭირს ცოტა. მაგრამ თუ შეუძლია ვინმეს დახმარება უყურადღებოდ არ დაგტოვებს 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 More sharing options...
sys32 Posted January 16, 2012 Share Posted January 16, 2012 for(i=0; i<5; i++) { cin>>n; if(i%2==0) sum+=n; } cout<<sum; ლუწ ინდექსიანიების ჯამი თუ ლუწების ჯამია საჭირო მაშინ n%2==0 და ესაა Link to comment Share on other sites More sharing options...
L1nux Posted January 16, 2012 Share Posted January 16, 2012 for(i=0; i<5; i++) { cin>>n; if(i%2==0) sum+=n; } cout<<sum; ლუწ ინდექსიანიების ჯამი თუ ლუწების ჯამია საჭირო მაშინ n%2==0 და ესაა მე ნახვას ვერ ვასწრებ ,და თვითონ შემოიხედავს მერე :) Link to comment Share on other sites More sharing options...
MCsanchez Posted January 17, 2012 Author Share Posted January 17, 2012 დიდი მადლობა ჯიგრები ხართ, მაგრად დამეხმარეთ ) Link to comment Share on other sites More sharing options...
gio_kiborg Posted January 17, 2012 Share Posted January 17, 2012 დავხურო? Link to comment Share on other sites More sharing options...
Recommended Posts