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

  Ansi-c program complete assignment as per written in the

complete assignment as per written in the

  Build a basic cipher base class

Build a randomly generated simple substitution cipher and use it to encode messages. Again the encoded messages will be in all upper case letters only.

  Calculates an employees wage for a week

Write a program that calculates an employee's wage for a week. An employee's wage is calculated as follows - if the number of hours is less than or equal to 40, then the total payment is hour rate

  Give the sequence of vertices

(a) Draw G. (b) Give the sequence of vertices visited using depth-first search starting a t vertex 1. (c) Give the sequence of vertices visited using breadth-first search starting at vertex 1.

  Create an object oriented solution customer to purchase

Create an object oriented solution that allows a customer to purchase between 1 and 3 pizzas, add toppings to each pizza, if desired, and then displays a receipt, including the details for each pizza, a pretax total amount, and a grand total amoun..

  Consider the following einf gramar for the simple calculator

Consider the following EINF gramar for the simple calculator language mentioned in class.

  Create an array of customer names

In preparation for more complex data processing tasks using object-oriented objects that you will create in up-coming units, in this unit you will utilize arrays to build some basic processing logic and structures.

  Write function that finds the minimum of three double value

1. Write a function that finds the minimum of three double values. This function should use another function that finds the minimum of two double values.

  Using the hotelroom class of programming problem

Using the HotelRoom class of Programming Problem 1 , Section 12.4 , write a program that uses an array Hotel [ ] of 200 HotelRoom pointers to store information about a set of hotel rooms . The program should ask the user to ent information about a ro..

  Program to input the length of the side from the keyboard

write a program to input the length of the side from the keyboard ,use the class to obtain the areas of all shapes and display the results on the screen

  Program for how to indicate the family member entry

Program for how to indicate the family member entry is complete

  Expressions until the user says

Expressions until the user says he or she wishes to end the program. For a more difficult assignment, enhance your program so that the expression need not be well formed; if it is not well formed, then the user is asked to reenter the expression.

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