We have an N x N square grid.


We will paint each square in the grid either black or white.

If we paint exactly A squares white, how many squares will be painted black?

A and N are integers,

Print the number of squares that will be painted black.
C++

Answers

Answer 1

Answer:

The solution in C++ is:

#include <iostream>

using namespace std;

int main(){

   int N, A;

   cout<<"Grids: ";    cin>>N;

   cout<<"White: ";    cin>>A;

   cout<<"Black: "<<N * N - A;

   return 0;

}

Explanation:

This declares N and A, as integers

   int N, A;

This gets inputs for N

   cout<<"Grids: ";    cin>>N;

This gets inputs for A, (the white grids)

   cout<<"White: ";    cin>>A;

This calculates and prints the number of black grids

   cout<<"Black: "<<N * N - A;

PS

From the question, we understand that the grid is N by N square grids.

This means that:

[tex]Total = N * N[/tex]

So, the number of black grids is:

[tex]Black = Total - A[/tex]


Related Questions

What do you do if your computer dies/malfunctions? Reboot (Restart) Shut Down Recovery CD and Recover your system Call a person to fix it​

Answers

Answer:

Restart

Explanation:

Simply I may restart my pc if it dies/malfunctions. I'll not restart immediately, I'll wait for an hour and do restart my computer. If it doesn't work then maybe I'll Call a person to fix it.

Fasilitas untuk pengaturan batas kertas pada Microsoft Word adalah….

a. Margin
b. View
c. LayOut
d. Paragraph

Office 92 sering disebut juga dengan….

a. Office 3.0
b. Office 7.0
c. Office Xp
d. Office 2.0


Answers

Fasilitas untuk pengaturan batas kertas pada Microsoft Word adalah

B.View

Office 92 sering disebut juga dengan

A.Office 3.0

explain the working principle of computer? can anyone tell​

Answers

Answer:

input process and output hehe

Write a program that asks the user to enter in a username and then examines that username to make sure it complies with the rules above. Here's a sample running of the program - note that you want to keep prompting the user until they supply you with a valid username:

Answers

user_in = input ("Please enter your username: " )

if user_in in "0123456789":

print ("Username cannot contain numbers")

elif user_in in "?":

print ("Username cannot continue special character")

else:

print (" Welcome to your ghetto, {0}! ".format(user_in))

Other Questions
el amor es uno de los temas constantes en su poesa. Los eruditos, scholars, dicen que ella amaba y era amada. Explain the reciprocal relationship between human society and limiting factors Write a sonnet using the traditional Shakespearean sonnet form. My flvs teacher said that she was asked to hold off on grading my assignment. She will give me a call back when when gets more information. Anyone have the same problem? The gluteus maximus is located superior to which muscle? Biceps brachii Erector spinae Gastrocnemius Brachioradialis Give the order of symmetry from the fig 3a)2b)3c)6d)4 Rationalize the denominator and simplify how many metres are there in of km Cu 2 State the syntactic function of the underlined parts:Example: He has learnt English for 3 years OdAdvocates of organic foods - a term (a) whose meaning varies greatly - frequently proclaim that such products are (b) safer and more nutritious than others. Mention any four challenge of sustainable development in nepal What is the purpose of the Arctic Circle?The Arctic Circle is an actual line. It marks the southernmost latitude at which the sun does not rise at least one day a year, and does not set at least one day a year. This makes for long days in summer and long nights during winter.The Arctic Circle is an imaginary line. It marks the northernmost latitude at which the sun does not rise at least one day a year, and does not set at least one day a year. This makes for long days in summer and long nights during winter.The Arctic Circle is an imaginary line. It marks the southernmost latitude at which the sun does not rise at least one day a year, and does not set at least one day a year. This makes for long days in summer and long nights during winter.The Arctic Circle is an actual line. It marks the northernmost latitude at which the sun does not rise at least one day a year, and does not set at least one day a year. This makes for long days in summer and long nights during winter. A convex mirror of radius of curvature 1.6 m has an object placed at a distance of 1.0 m from it. Find the position of image and the magnification. Solve the equation sine =0.6792 for 0360 Jamon is a manager in a human resources organization. He has a message for Bob who works on the assembly line. What channel is he likely to use get the message to Bob For a reaction: aA Products, [A]o -4.3 M, and the first two half-lives are 56 and 28 minutes, respectively. Calculate k (without units). Show Work!A. 7.7 x 10^-2 B. 4.2 x 10^-3 C. 3.8 x 10^-2 D. 8.3 x 10^-3 E. None of these how are Nepalese people interrelated to each other? What is the solution to this equation?log_8 16 + 2log_8x =2 Which inequality is shown in the graph?I need help plz if (a + b) = 73 and a b =65 find value of a+ b Which is a mixture?Sodium metalchlonne gassodium metal and chlonne gassodium chlonde (salt) and water