
ابي احد ايساعدني في حل السؤال
Part 1:
Write a function template named Count_Key that takes as parameters an array, a key value, and the size of the array.
The function should return how many times the key value repeated in the array.
Note:the array can be of any data type.
Write a main function to test your program.
PHP:template<class int> int Count_Key (int ar[],int key,int size ){ for(int i=0;i<size;i++){ if(ar[i]==key) return key; } return 0; } int main(){ cout<<Count_Key ( ar[],4,int size ) system("pause"); return 0; }
^^^^
في الـmain , ليش حاطة char t
المطلوب يدخل سترنج مو حرف
ولازم بعد تنادين الفنكشن في المين .
الفنكشن , اعتقد اعتقد تقدرين تستخدمين الفنكشنز find or substr
والـ w من وين جت , خلي الـ t في الفنكشن
وأمر بالطباعة عشان يطبع لج
عندي بعد سؤالمشكووورة أختي كود على التوضيح
عدلته حسب كلامش
بس ما أدري صح أولا
هذا حلي
#include<iostream>
#include<string>
using namespace std;
void printLineReversed(string t)
{
if(t!='\n')
return;
else
printLineReversed();
cout<<substr(t)<<endl;
}
int main()
{
printLineReversed("ITCS102");
return 0;
}
بسألش أختي
أني إلي فهمته من السؤال إذا وصل إلى سطر جديد يرجع
صح أو لا؟؟؟؟
يعني المفروض أِشيل != في if
صح هذا الكلام؟؟؟؟؟
\ائماً يطلع لي ايرور عند if ليش؟؟؟؟
ثانياً شلون أخليه يطبعهم بالعكس؟؟؟؟؟
مشكووورة أختي..ما قصرتين
آ , في شي ما انتبهنا له اختي
الفنكشن لازم تقرأ السترنغ , يعني مو نطرشه لها
which reads a line of text from the user
char s;
cin.get(s);
\\n=10
حاولي في الفنكشن نفسها حطي :
PHP:char s; cin.get(s);
وعشان توقف , لازم توصل لنهاية السطر اللي اهو n\
اذا حطيتينه في الـ if جذي ما بيرضى , بيطلع ايرور
بناخذ قيمته بالstatic_cast , يعني بنقارن كاركتر بكاركتر
الـسلاش إن =10
PHP:\\n=10
if( num == 1)
return 1;
int fact( int num)
{
if( num == 1)
return 1;
else
{
return (num * (fact(num-1)));
}
}



recursion_fun(infile);
void recursion_fun(ifstream &infile)
{ string word;
if(infile.eof())
{cout<<" ";}
else{
infile>>word;
recursion_fun(infile);
cout<<word<<" ";
}
}
[COLOR="White"]int check(char answer[],int size,char key[])
{
int counter=0;
if(size<0)
return 0;
else{
{if(answer[size--]==key[size--])
counter++;}
return check(answer,size--,key)+(counter++);
}
} [/COLOR]
