Wednesday, 24.04.2024, 11:26
Welcome Guest | RSS
Site menu
Login form
Section categories
Search
Calendar
«  April 2024  »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
282930
Entries archive
Our poll
Rate my site
Total of answers: 6
Statistics

Total online: 1
Guests: 1
Users: 0

Main » C++ programs
#include <iostream>
#include <cstdlib>
using namespace std;

long long Exp(long long base, long long exp)
{
long long r=base;
for(int i=1;i<exp;i++)
r*=base;
return r;
}

int main()
{
long long A,B;
long long base,mod;
for(;;)
{
cout << "Base: " << endl;
cin >>base;
cout << "Modulus: " << endl;
cin >>mod;
cout << "Alice, choose your secret number: " << endl;
cin >>A;
cout << "Bob, choose your secret number: " << endl;
cin >>B;
long long a=Exp(base,A)%mod;
long long b=Exp(base,B)%mod;
cout << "Alice's value: " << a << endl;
cout << "Bob's value: " << b << endl;
long long akey=Exp(b,A)%mod;
long long bkey=Exp(a,B)%mod;
cout << "Alice's key: " << akey << endl;
cout << "Bob's key: " << bkey << endl;
}
system("PAUSE");
return EX ... Read more »
Category: C++ programs | Views: 533 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

#define arg dbl a,dbl b,dbl c
#define dbl double

dbl max1(arg){
    a=(a>b ? (a>c ? a:c) : (b>c ? b : c));
    return a;
}

dbl min1(arg){
    a=(a<b ? (a<c ? a : c) :(b<c ? b : c));
    return a;
}

dbl sum1(arg){
    return a+b+c;
}

dbl average1(arg){
    return (a+b+c)/3;
}

int main(){
    dbl x,y,z,m,s,d,e;
    cout<<"please enter the first value"<<endl;
    cin>>x;
    cout<<"please enter the second value"<<endl;
    cin>>y;
    cout<<"please enter the third value"<<endl;
    cin>>z;
    s=sum1(x,y,z);
    m=average1(x,y,z);
 &nbs ... Read more »
Category: C++ programs | Views: 520 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

//Note, this works only by GCC compiler
#include <iostream>
#include <fstream>
using namespace std;

#define r m

int bazm(int x,int y){

    return (x*y);
}

int main()
{
    cout<<"Enter the quantity of numbers"<<endl;
    int m;
    cin>>m;
    ofstream out("out.txt");
    int i, j;
    int a[r][r];
    for (i=0;i<r;i++){
    for (j=0;j<r;j++)
    a[i][j]=bazm(i,j);
    }

 for (i=0;i<r;i++){
    out<<endl;
    for (j=0;j<r;j++)
        out<<i<<" * "<<j<<" = "<<a[i][j]<<endl;
            }
      &n ... Read more »
Category: C++ programs | Views: 538 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int main()
{
    int n, tiv;
    cin>>n;
    if(n>=1){
        if(n<=9){
    for(tiv=1;tiv<=n;tiv++){
    cout<<n;
    }}}
    return 0;
}

Category: C++ programs | Views: 519 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int main()
{
   char a;
   cin>>a;
   a|=(1<<5);
   cout<<a<<endl;
   cin.get();
   return 0;
}

Category: C++ programs | Views: 568 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int main()
{
   char a;
   cin>>a;
   a^=(1<<5);
   cout<<a;
   cin.get();
   return 0;
}

Category: C++ programs | Views: 543 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>
using namespace std;
int main()
{
    int num;
    for(;;){
    cin>>num;
        do
        {
            cout<<num%10;
            num/=10;
        }
        while(num>0);
        cout<<endl<<"\n";
    }
    return 0;
}

Category: C++ programs | Views: 557 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int modInverse(int a, int n) {
 int i = n, v = 0, d = 1;
 while (a>0) {
  int t = i/a, x = a;
  a = i % x;
  i = x;
  x = d;
  d = v - t*x;
  v = x;
 }
 v %= n;
 if (v<0) v = (v+n)%n;
 return v;
}

int main()
{
    cout << modInverse(8,16);
    return 0;
}

Category: C++ programs | Views: 510 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int shrjum(int tiv) {
    int n=1, t = tiv;
    while ((t/10)!=0) {
        t/=10; n *=10;
        }
    if (tiv>=10)
    return (n*(tiv%10)) + shrjum(tiv/10);
    else
    return (tiv%10);
    }

int main(){
    int x;
    cin>>x;
    cout<<shrjum(x);
    return 0;
}

Category: C++ programs | Views: 519 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

#include <iostream>

using namespace std;

int main()
{
    int x,a(0);
    cin>>x;
    do{
    a*=10;
    a+=x%10;
    x/=10;
    }while(x>0);
    cout<<a;
    return 0;
}

Category: C++ programs | Views: 486 | Added by: H_Imirzyan | Date: 10.06.2011 | Comments (0)

« 1 2 3 »