Checkout
checkout
view
Your Cart Your Cart: item(s)
Subjects -> Computer Science -> Other -> Posting #50925
Add to Shopping Cart
$2.19 Instant Download
Computer Science, Other
Year 1

Chinese Remainder Theorem Visual C++.NET 2003


Hi
I need help to writing a program "VC++.net"with the specified input and output.

Please, Implement the Chinese Remainder Theorem. Allowing at least 3 pairwise relatively prime positive integers.

Please attention
This program must run in the Visual C++.NET. Some time I have problem with that, so, please the whole project included in the attached Zip file.

I already tried writing this program but I couldn't run it. I send that, I hope be useful.


//project #1



#include
#include
#include

int gcd(int,int);
int inverse(int,int);

void main(){

int x, Remainder[4], Num[4], M=1, Ma[4], Myarray[4]={0,0,0,0},i;

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

{
    

  cout<<"  nn           X = A (MODULUS M)     nn";
cout<<"             PLEASE ENTER YOUR NUMBER :nnn ";
cin>>Remainder[i];
cout<<"           PLEASE ENTER YOUR NEXT NUMBER :nnn";

cin>>Num[i];
cout<<"              AND NOW YOUR NUMBER IS  = "
  
<< Remainder[i] << "  ( mod  "  << Num[i]<< " ) ";


M = M * Num[i];

cout<

Ma[i] = M/Num[i];
cout<< " nn  M =  "<< Ma[i] << "Modulus" << Num[i]<<" ( "<< Ma[i] <<" = "<< Remainder[i]<<" )n";

Myarray[i]= gcd(Ma[i], Num[i]);
Myarray[i]= inverse(Ma[i], Num[i]);

x=Remainder[0]*Ma[0]*Myarray[0]+Remainder[1]*Ma[1]*Myarray[1]+Remainder[2]*Ma[2]*Myarray[2];
x=x%M;
cout <cout<<"        x = "<}

system ("pause");
}
int inverse(int a, int b)
{
int x=1;

while (a*x%b !=1)
{
x++;
}
return x;
}

int gcd(int Num, int n)
{


int Remainder;
while (n!=0)
{
Remainder = Num %n;
Num=n;
n=Remainder;
}
return Num;
}

By OTA:  Israel Kovner, PhD

OTA Rating:  5/5

Your Price:  $2.19  (original value ~$19.95)

What's included:

  • Plain text response
  • Attachment(s):
    • ChineseRemainderTheorem.zip
$2.19 Download Add to Cart

Add to Shopping Cart
$2.19 Instant Download

Page generated in 0.0126 seconds

About Us ·  Contact Us ·  Samples ·  Solutions ·  Legal Terms and Conditions ·  Privacy Policy

©2008 SolutionLibrary.com

Search for Solutions About Us Samples