هذا هو الحل بدون توابع التعامل مع المحارف يرجى الاطلاع لمن يهمه الأمر
كود PHP:
#include<iostream.h>
#include<math.h>
#include<stdlib.h>
void Display(void);
void Choise (char);
void Prime(int , int) ;
double PI ( double );
void rev_order(int) ;
void main()
{
char c;
while(1)
{
Display();
cin >> c ;
Choise(c) ;
}
return ;
}
void Display(void)
{
cout << "Welcome This is the program menu Please Print the number your choice"<< endl
<< "1. Numeric calculation " << endl
<< " a. Prime numbers " << endl
<< " b. Pi approxmiation " << endl
<< " c. Reverse order " << endl
<< endl
<< "2. Text Analysis " << endl
<< "3. Searching a text " << endl
<< "4. Exit " << endl ;
}
void Choise(char c)
{
switch( c )
{
case 'a':
{
int a , b ;
cout << " Enter two numbers a , b " << endl ;
cin >> a >> b ;
Prime(a , b) ;
}
break ;
case 'b':
{
double n ;
cout << "Please enter a number " << endl ;
cin >> n ;
cout << PI(n) << " is approximtly to " << n << endl ;
}
break ;
case 'c':
{
int k ;
cout << "Enter anumber " << endl ;
cin >> k ;
rev_order(k);
}
break ;
case '4' :
exit(1);
default:
cout << " You choise is not correct " << endl;
}
}
void Prime(int a , int b)
{
bool D ;
for(int i = a ; i <= b ; i++)
{
D = true ;
for(int j = 2 ; j <= i/2 ; j++)
{
if(i%j == 0)
{
D = false ;
break ;
}
}
if(D)
cout << i << " " ;
}
}
double PI(double n)
{
return floor(n) ;
}
void rev_order(int k)
{
cout << " The Reverse of " << k << " is " ;
int rk = 0 ;
while(k/10 != 0)
{
rk *= 10 ;
rk += k%10 ;
k = k/10 ;
}
cout << rk*10 + 1 << endl ;
}