C :: Writing Number In The Middle Of Hollow Rectangle
Oct 3, 2014
I want to put number in the center of the rectngle. Nonetheless, one space is residual.
Code:
#include <stdio.h>
nt main(){
int i,j;
int column,row;
int n;
printf("Enter column: ");
scanf("%d",&column);
[Code] .....
View 14 Replies
ADVERTISEMENT
Sep 7, 2012
I want to edit the contents of a file using fstream, but none of the modes in the fstream constructor work for me.
If I use ios::trunc, then the whole file is deleted - but I want to retain the contents and edit it. If I use ios::app, then I can only add data to the end of the file - but I want to edit the data in the middle of the file. If I use ios::ate, then the whole file is deleted again, similar to ios::trunc.
How can I create an fstream object without deleting the contents of the file, whilst still being able to move the pointer arbitrarily around in the file with seekp() (and not just placing it at the end as with ios::app)?
View 3 Replies
View Related
Oct 4, 2014
How to draw a hollow triangle given a user input indicating the number of rows.
Eg:
Number of rows = 4
___*
__*_*
_*___*
*******
My idea was to split up the triangle into three parts (first row, middle part, last row) and I've managed to write some code on printing the first and last row of the triangle
Code:
int main() {
//Declaring the variables.
int rows, position;
//Prompts user to enter number of rows.
printf("Enter the number of rows in the triangle: ");
scanf("%d", &rows);
[Code] .....
What to do so that I can print the middle part of the triangle. All I know is that I need to use loops. I've also been told that drawing a flow chart would work but I really don't know how to even begin with a flow chart then transform it into code.
View 2 Replies
View Related
Oct 4, 2014
the code draws rectangle or square it depends on you (column,row) then, put number in the center of the rectangle i don't want to extra space after putting one,two,three or four digits number in the center of the rectangle
#include <stdio.h>
int main(){
int i,j;
[Code]....
View 3 Replies
View Related
May 13, 2014
Consider I have a rectangle like this:
Point p1(100,100);
Point p2(300,200);
Graph_lib::Rectangle r(p1,p2);
And also I have a function that takes a rectangle and returns a Point of that, say, top-left corner of that rectangle. For example:
Point N(Graph_lib::Rectangle R1);
My question is that, first, how to send that Rectangle r(p1,p2) to the Point N(Graph_lib::Rectangle R1) function? And then, how to return a Point from that function?
My IDE is visual studio 2012.
View 19 Replies
View Related
Sep 11, 2013
im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output
#include <iostream>
#include<iomanip>
using namespace std;
[Code]....
View 3 Replies
View Related
Oct 24, 2014
write a program that computes the factorial of a number and displays it. A factorial of a number (written N!) is defined as N * (N-1) * (N-2) * (N-3) ... *1 In other words, 5! = 5 * 4 * 3 * 2 * 1 = 120 and 3! = 3 * 2 * 1 + 6.
Example of output 15 is 1.30767e+012
Can't get it to display error when user enters a number lower than 2 or higher 60.
// Program to calculate factorial of a number
#include <iostream>
#include <iomanip>
[Code].....
View 13 Replies
View Related
Feb 28, 2015
I am able to display a filled and hollow square by themselves, but I can't seem to be able to get them side by side.
So this is my code so far:
[/
#include <iostream>
using namespace std;
int main()
[Code]....
I can get the hollow square to show up, but the first square just shows up as a single line instead of a square. It seems that it ignores the first if statement in the second loop. I've tried not using an if statement in the second loop but it didn't seem to work either.
View 4 Replies
View Related
Feb 17, 2013
I'm trying to make a function that lets me pass an index and a string and will insert the string at that index in the linkedlist..
Code:
typedef struct node {
char* value;
struct node* next;
}
[code].....
View 4 Replies
View Related
Mar 12, 2014
Above you said to find the middle value you should divide the array by two and then display the middle value (aka the median). For example, for an array consisting of 1 2 3 4 5, 3 would be the middle value.
My question is, how/what do I write to tell the program to display the middle value???
So far, I have done enough research and written enough code to receive values from the user and sort the array in ascending order. I simply don't know where to go from here (I started C++ about 1 month ago). I don't know how to tell it to pull the middle value.
I've researched "find_if", "nth_value" and a boat load of others with no luck
Here's what I've done so far:
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
[Code]....
View 3 Replies
View Related
Aug 2, 2014
I was given some practice problems in my programming class, to prepare for the final and I don't quite understand what this one is asking for exactly:
Write the remainder of the program to find the maximum value for the middle row of the array data. Print the max after finding it. Your code should work for any 2D array of ints with three rows and four columns, so don't hard-code your program to these specific values.
Code:
#include <stdio.h>
int main(void)
{
int data[][4] = {{ 5, 8, 7, 2},
{ 3, 10, 1, 9},
{ 6, 12, 5, 0}};
View 8 Replies
View Related
Sep 18, 2013
A user enters a query and other users reply to it. But it creates a problem here. After adding queries, if I wish to reply to query in between then it adds a redundant entry in file. 1st entry is the original query without reply and 2nd entry is the same query now with a reply added. I want only 1 entry of the query along with replies.Here is the code:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include "var.c"
int check_count();
void add_query();
void add_reply();
}
[code]....
View 9 Replies
View Related
May 1, 2013
I am trying to delete a node from the end of a Linked List but I have some problems. Every node has it's unique code. Here is what I do:
1. Ask the user for the unique code of the node.
2. Ask him if he wants to change the data in it or delete the whole node.
3. If he chooses to delete it, I do this:
//let's say that temp1 points to the node
List *temp2 = temp1;
temp1 = temp1->next;
delete temp2;
And it's just not deleting the node.
View 2 Replies
View Related
Jan 17, 2015
I'm trying to create a program which can pan by keep clicking and move the mouse
1. First, I create a class that inherited from the UserControl Class
public partial class CanvasCtrl : UserControl
protected void OnMiddleMouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Middle) {
[Code] ....
2, Second, I create the void in that class too, and write the code to get it to catch the event
public void MainMouseAction() {
this.MouseClick += new MouseEventHandler(OnMiddleMouseDown);
}
It not work, how to solve this out ?
View 8 Replies
View Related
Jan 24, 2013
I created a structure containing two variables of type char.
i.e. char name[64],char details[128];
And a pointer to structure now when I write this name and details to file and now I want to change the particular name.
i.e. To modify then if the stored file name is greater than the entered name then it is erasing the next record line also I need to allocate some memory.
View 2 Replies
View Related
Nov 23, 2013
I program a software to get scores from admin and sort them ascending then show the middle score(if admin enter middle).but when i compile it nothing happen.what should i do?here's code ,i use dev compiler
Code:
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main(int argc, char *argv[]) {
int counter,j,count,counter2,m;
[Code] ....
View 14 Replies
View Related
Oct 24, 2014
I've a problem here...
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
[Code] ....
The program needs to be able to read the middle names within the text file named Info2.txt
Simply adding the Mname or any related value where the other to name values doesn't do anything and only the 1st line appears on the output.
Don Jon111012
Jack Bo Todd151015
Jill Jo Jane161011
Bob Jack Chuck 131513
Da Fu111012
That is the correct way it appears in the text file. Also I know it's commented out, but that just to keep the program from crashing.
current output
Survey Results:
Name Results
Don Jon 33.00
This is the Info1.txt file info by the way.
Ken A202017
Gus B151015
Bill C151512
Jara C151720
Lu E101510
Chow B171015
And the output
Survey Results:
Name Results
Ken A 57.00
Gus B40.00
Bill C42.00
Jara C52.00
Lu E35.00
Chow B 42.00
Which when ran with Info1 selected, it is the correct output I'm looking for. I've tried getline and other solutions and they didn't work.
View 1 Replies
View Related
Sep 17, 2014
I'm trying to draw and pivot a rectangle. How to get the new coordinates if I turn it 90 degree for example?
From this:
To this:
This is not good because it will reduce it in size.
Code:
int size = 50;
if(b) // draw rectangle
{
POINT points[4] =
{{xCoord, yCoord},
[Code] ....
View 7 Replies
View Related
Jan 27, 2015
I'm trying to make a program that prints a rectangle using "*" asterisks. I am only allowed to use "for loops" and I simply cannot get this to work properly. Here is my code so far...
Code:
int main(void)
{
//RectangleSize represents the area of the rectangle(width*length)
int length, width, RectangleSize;
[Code].....
View 5 Replies
View Related
Nov 2, 2013
I am trying to create a rectangle with 3*5 dimension which would look like:
#####
#####
#####
I wanted to use for, and do while loop for that programming. I couldn't been able to create my desired dimension of 3*5.
//complier directives
#include<iostream>
#include<cstdlib>
using namespace std;
//main body
int main () {
//local identifiers
//complier directives
[Code] .....
View 5 Replies
View Related
Apr 6, 2013
how to use 3 variables to represent a rectangle in a grid instead of using 4. The traditional way is to use (x,y) (x2,y2). I propose using (x,l,h).In the traditional way as you probably know, (x,y) is the left op most corner, and (x2,y2) is the bottom right most corner. In the way I am proposing X is the left side, l is the length of the top side, and also the length of the bottom. 'h' is the height of the left and right. I think it's obvious how these three can define a rectangle same as the four.
View 2 Replies
View Related
Mar 11, 2014
I have having trouble looping through the list in the update section to update each object in the rectangleList. I am not sure how to format it because it is only drawing one and it does not move across the screen. I thought this section of code would work and loop through each object and make each one move but it does not.
for (int i = 0; i < rectangleList.Count; i++) {
enemyPosition = new Rectangle(rectangleList[i].X + 2, rectangleList[i].Y ,enemyPosition.Width,enemyPosition.Height);
} List<Rectangle> rectangleList;
protected override void Initialize() {
rectangleList = new List<Rectangle>();
[code].....
View 5 Replies
View Related
Apr 26, 2012
I am making a game Pong, and have been struggling with the collision aspect between the baal hitting off the paddle. I have created a Class, to draw a rectangle, to work with collision however I dont know how to assign the rectangle to the images of the ball and paddle.
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <vector>
#include <cmath>
#include "gwin.h"
const int NUMBEROFBALLS = 1;
[Code] .....
View 1 Replies
View Related
Jan 30, 2015
I am new to C and am unfortunately racking my brain against this simple assignment. I believe the task is to produce a rectangle out of asterisks using while loops, yet I can only produce an "L" shape. We were given a code, with syntax errors included.We are to correct the errors and test.
Code:
#include <stdio.h>
/*Houghton, Micah*/
/*ET2560 - Cordova*/
/*Unit 5 Lab - Programming Loops*/
int main(void) {
int length, width;
int lcount, wcount;
[code]....
View 3 Replies
View Related
Feb 17, 2014
#include <iostream>
#include <cmath>
using namespace std;
//prototypes for all separate functions
int chooseFunc(int);
int chooseMethod(int);
int numRect(int);
[Code] .....
It seems that my program will ask the user for the number of rectangles and trapezoids but will fail to compute the area under the curve from the user input. Therefore, I believe I have a logical error somewhere or I'm forgetting to call something somewhere.
View 1 Replies
View Related
Oct 5, 2013
I want to detect colors that in the black rectangle. [URL] How can I do? What library should I use?
View 7 Replies
View Related