SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Downloaden Sie, um offline zu lesen
namespace Habib_OLA4
{
internal class Program
{
private int[] digits;
public BigNumber()
{
digits = new int[40];
}
public void Input(string input)
{
int startIndex = 0;
bool isNegative = false;
if (input[0] == '-')
{
isNegative = true;
startIndex = 1;
}
for (int i = 0; i < digits.Length; i++)
{
digits[i] = 0;
}
for (int i = startIndex; i < input.Length; i++)
{
digits[digits.Length - input.Length + i] = input[i] - '0';
}
if (isNegative)
{
Negate();
}
}
public override string ToString()
{
int startIndex = 0;
while (startIndex < digits.Length - 1 && digits[startIndex] == 0)
{
startIndex++;
}
if (digits[startIndex] < 0)
{
return "-" + new BigNumber(digits).ToString();
}
char[] chars = new char[digits.Length - startIndex];
for (int i = 0; i < chars.Length; i++)
{
chars[i] = (char)(digits[startIndex + i] + '0');
}
return new string(chars);
}
public BigNumber Add(BigNumber other)
{
BigNumber result = new BigNumber();
int carry = 0;
for (int i = digits.Length - 1; i >= 0; i--)
{
int sum = digits[i] + other.digits[i] + carry;
result.digits[i] = sum % 10;
carry = sum / 10;
}
return result;
}
public BigNumber Subtract(BigNumber other)
{
BigNumber result = new BigNumber();
int borrow = 0;
for (int i = digits.Length - 1; i >= 0; i--)
{
int difference = digits[i] - other.digits[i] - borrow;
if (difference < 0)
{
difference += 10;
borrow = 1;
}
else
{
borrow = 0;
}
result.digits[i] = difference;
}
return result;
}
public bool IsEqualTo(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] != other.digits[i])
{
return false;
}
}
return true;
}
public bool IsNotEqualTo(BigNumber other)
{
return !IsEqualTo(other);
}
public bool IsGreaterThan(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] > other.digits[i])
{
return true;
}
else if (digits[i] < other.digits[i])
{
return false;
}
}
return false;
}
public bool IsLessThan(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] < other.digits[i])
{
return true;
}
else if (digits[i] > other.digits[i])
{
return false;
}
}
return false;
}
public bool IsGreaterThanOrEqualTo(BigNumber other)
{
for (int i = 0; i > digits.Length; i++)
{
if (digits[i] > other.digits[i])
{
return true;
}
else if (digits[i] < other.digits[i])
{
return false;
}
}
return false;
}
public static void Main(string[] args)
{
BigNumber integer1 = new BigNumber();
BigNumber integer2 = new BigNumber();
Console.Write("Enter first BigNumber: ");
integer1.Input(Console.ReadLine());
Console.Write("Enter second BigNumber: ");
integer2.Input(Console.ReadLine());
Console.WriteLine($"BigNumber 1: {integer1}");
Console.WriteLine($"BigNumber 2: {integer2}");
BigNumber result;
// add two BigNumbers
result = integer1.Add(integer2);
Console.WriteLine($"Add result: {result}");
// subtract two BigNumbers
result = integer1.Subtract(integer2);
Console.WriteLine($"Subtract result: {result}");
// compare two BigNumbers
Console.WriteLine($"BigNumber 1 is zero: {integer1.IsZero()}");
Console.WriteLine($"BigNumber 2 is zero: {integer2.IsZero()}");
Console.WriteLine($"BigNumber 1 is equal to BigNumber 2:
{integer1.IsEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is not equal to BigNumber 2:
{integer1.IsNotEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is greater than BigNumber 2:
{integer1.IsGreaterThan(integer2)}");
Console.WriteLine($"BigNumber 1 is less than BigNumber 2:
{integer1.IsLessThan(integer2)}");
Console.WriteLine($"BigNumber 1 is greater than or equal to BigNumber 2:
{integer1.IsGreaterThanOrEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is less than or equal to BigNumber 2:
{integer1.IsLessThanOrEqualTo(integer2)}");
}
}
}
I have an error.
//This what the output support to look like
Sample Run 1:
Enter first BigNumber: 1234567890123456789012345678901234567890
Enter second BigNumber: 0987654321098765432109876543210987654321
BigNumber 1: 1234567890123456789012345678901234567890
BigNumber 2: 987654321098765432109876543210987654321
Add result: 2222222211222222221122222222112222222211
Subtract result: 246913569024691356902469135690246913569
BigNumber 1 is zero: False
BigNumber 2 is zero: False
BigNumber 1 is equal to BigNumber 2: False
BigNumber 1 is not equal to BigNumber 2: True
BigNumber 1 is greater than BigNumber 2: True
BigNumber 1 is less than BigNumber 2: False
BigNumber 1 is greater than or equal to BigNumber 2: True
BigNumber 1 is less than or equal to BigNumber 2: False
Press any key to continue . . .
Can you help me with the c# program?

Weitere ähnliche Inhalte

Ähnlich wie namespace Habib_OLA4 { internal class Program { .pdf

Please help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxPlease help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxJakeT2gGrayp
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdfsudhinjv
 
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfinclude ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfadisainternational
 
2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrayskinan keshkeh
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfanithareadymade
 
class Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdfclass Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdftrishacolsyn25353
 
public class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfpublic class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfanjanadistribution
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - ReferenceMohammed Sikander
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryNikolaos Tsantalis
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016Jeff Chu
 

Ähnlich wie namespace Habib_OLA4 { internal class Program { .pdf (19)

Please help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxPlease help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docx
 
types.pdf
types.pdftypes.pdf
types.pdf
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf
 
C programs
C programsC programs
C programs
 
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfinclude ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
 
2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays
 
cosc 281 hw2
cosc 281 hw2cosc 281 hw2
cosc 281 hw2
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 
Lab Question
Lab QuestionLab Question
Lab Question
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdf
 
Code
CodeCode
Code
 
class Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdfclass Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdf
 
public class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfpublic class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdf
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit History
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016
 

Mehr von amazonedistributors

Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfNeed help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfamazonedistributors
 
Need correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfNeed correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfamazonedistributors
 
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfNecesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfamazonedistributors
 
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfNecesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfamazonedistributors
 
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfNash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfamazonedistributors
 
NASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfNASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfamazonedistributors
 
Name these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfName these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfamazonedistributors
 
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfn2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfamazonedistributors
 
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfNo plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfamazonedistributors
 
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfno need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfamazonedistributors
 
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfNonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfamazonedistributors
 
North Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfNorth Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfamazonedistributors
 
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfNoel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfamazonedistributors
 
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfNike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfamazonedistributors
 
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfNinna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfamazonedistributors
 
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfNike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfamazonedistributors
 
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfNIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfamazonedistributors
 
Nicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfNicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfamazonedistributors
 
NetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfNetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfamazonedistributors
 
Network Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfNetwork Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfamazonedistributors
 

Mehr von amazonedistributors (20)

Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfNeed help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
 
Need correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfNeed correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdf
 
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfNecesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
 
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfNecesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
 
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfNash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
 
NASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfNASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdf
 
Name these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfName these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdf
 
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfn2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
 
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfNo plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
 
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfno need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
 
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfNonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
 
North Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfNorth Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdf
 
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfNoel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
 
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfNike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
 
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfNinna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
 
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfNike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
 
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfNIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
 
Nicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfNicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdf
 
NetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfNetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdf
 
Network Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfNetwork Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdf
 

Kürzlich hochgeladen

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Kürzlich hochgeladen (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

namespace Habib_OLA4 { internal class Program { .pdf

  • 1. namespace Habib_OLA4 { internal class Program { private int[] digits; public BigNumber() { digits = new int[40]; } public void Input(string input) { int startIndex = 0; bool isNegative = false; if (input[0] == '-') { isNegative = true; startIndex = 1; } for (int i = 0; i < digits.Length; i++) { digits[i] = 0; } for (int i = startIndex; i < input.Length; i++) { digits[digits.Length - input.Length + i] = input[i] - '0'; } if (isNegative) { Negate(); } } public override string ToString() { int startIndex = 0; while (startIndex < digits.Length - 1 && digits[startIndex] == 0)
  • 2. { startIndex++; } if (digits[startIndex] < 0) { return "-" + new BigNumber(digits).ToString(); } char[] chars = new char[digits.Length - startIndex]; for (int i = 0; i < chars.Length; i++) { chars[i] = (char)(digits[startIndex + i] + '0'); } return new string(chars); } public BigNumber Add(BigNumber other) { BigNumber result = new BigNumber(); int carry = 0; for (int i = digits.Length - 1; i >= 0; i--) { int sum = digits[i] + other.digits[i] + carry; result.digits[i] = sum % 10; carry = sum / 10; } return result; } public BigNumber Subtract(BigNumber other) { BigNumber result = new BigNumber(); int borrow = 0; for (int i = digits.Length - 1; i >= 0; i--) { int difference = digits[i] - other.digits[i] - borrow; if (difference < 0) { difference += 10;
  • 3. borrow = 1; } else { borrow = 0; } result.digits[i] = difference; } return result; } public bool IsEqualTo(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] != other.digits[i]) { return false; } } return true; } public bool IsNotEqualTo(BigNumber other) { return !IsEqualTo(other); } public bool IsGreaterThan(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] > other.digits[i]) { return true; } else if (digits[i] < other.digits[i]) { return false;
  • 4. } } return false; } public bool IsLessThan(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] < other.digits[i]) { return true; } else if (digits[i] > other.digits[i]) { return false; } } return false; } public bool IsGreaterThanOrEqualTo(BigNumber other) { for (int i = 0; i > digits.Length; i++) { if (digits[i] > other.digits[i]) { return true; } else if (digits[i] < other.digits[i]) { return false; } } return false; } public static void Main(string[] args) {
  • 5. BigNumber integer1 = new BigNumber(); BigNumber integer2 = new BigNumber(); Console.Write("Enter first BigNumber: "); integer1.Input(Console.ReadLine()); Console.Write("Enter second BigNumber: "); integer2.Input(Console.ReadLine()); Console.WriteLine($"BigNumber 1: {integer1}"); Console.WriteLine($"BigNumber 2: {integer2}"); BigNumber result; // add two BigNumbers result = integer1.Add(integer2); Console.WriteLine($"Add result: {result}"); // subtract two BigNumbers result = integer1.Subtract(integer2); Console.WriteLine($"Subtract result: {result}"); // compare two BigNumbers Console.WriteLine($"BigNumber 1 is zero: {integer1.IsZero()}"); Console.WriteLine($"BigNumber 2 is zero: {integer2.IsZero()}"); Console.WriteLine($"BigNumber 1 is equal to BigNumber 2: {integer1.IsEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is not equal to BigNumber 2: {integer1.IsNotEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is greater than BigNumber 2: {integer1.IsGreaterThan(integer2)}"); Console.WriteLine($"BigNumber 1 is less than BigNumber 2: {integer1.IsLessThan(integer2)}"); Console.WriteLine($"BigNumber 1 is greater than or equal to BigNumber 2: {integer1.IsGreaterThanOrEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is less than or equal to BigNumber 2: {integer1.IsLessThanOrEqualTo(integer2)}"); } } } I have an error.
  • 6. //This what the output support to look like Sample Run 1: Enter first BigNumber: 1234567890123456789012345678901234567890 Enter second BigNumber: 0987654321098765432109876543210987654321 BigNumber 1: 1234567890123456789012345678901234567890 BigNumber 2: 987654321098765432109876543210987654321 Add result: 2222222211222222221122222222112222222211 Subtract result: 246913569024691356902469135690246913569 BigNumber 1 is zero: False BigNumber 2 is zero: False BigNumber 1 is equal to BigNumber 2: False BigNumber 1 is not equal to BigNumber 2: True BigNumber 1 is greater than BigNumber 2: True BigNumber 1 is less than BigNumber 2: False BigNumber 1 is greater than or equal to BigNumber 2: True BigNumber 1 is less than or equal to BigNumber 2: False Press any key to continue . . . Can you help me with the c# program?