Implement the chinese remainder theorem

Assignment Help C/C++ Programming
Reference no: EM13938500

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 <iostream.h>
#include <stdlib.h>
#include <math.h>

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<<M<<"n";

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 <<endl;
cout<<" x = "<<x<<" ( Mod"<<M<<" )n";
}

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;
}

Reference no: EM13938500

Questions Cloud

Why would that cause a physiological change : Why would administering bicarbonate to a patient be advisable if his blood pH was too low? What is the bicarbonate going to do to adjust the pH of the blood?
You report statistical data in this article : The article should follow similar headings to your abstract (the first four only) though you may have additional subheadings specific to your topic. It is not expected that you report statistical data in this article. You can however provide a cri..
Why muscle action potentials only the result of excitation : How do voltage-gated calcium channels relate to electrical activity of the neuronal vs. sarcolemmal membrane? Concentrate on the differences. Keep your answer brief (3-4 sentences).
About six days to receive and deposit checks from customers : It takes Cookie Cutter Modular Homes, Inc., about six days to receive and deposit checks from customers. Cookie Cutter’s management is considering a lockbox system to reduce the firm’s collection times. It is expected that the lockbox system will red..
Implement the chinese remainder theorem : 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.
Are the proposed actions of ed and robin ethical : Are the proposed actions of Ed and Robin ethical? What is the likely effect of their actions on shareholder value?
Report for advanced control : Abstract- These instructions give you guidelines for preparing your report for Advanced Control and are based on the templates used for scientific publications. Use this document as a template if you are using Microsoft Word.
Determine the current ratio after accounting for information : Determine the current ratio after accounting for the additional information. Explain why ABC's current ratio deteriorated so badly.
What muscles would be related to the symptom of diplopia : Based on the neurological exam results in this case, what cranial nerve and central fiber tracts are involved? What functions are those cranial nerves or fiber tracts responsible for?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd