Visual C++ :: Custom Pyramid Drawing Program

Jul 6, 2014

I am trying to figure out how to create a program that will draw a triangle using *'s with a base the has a user-inputted number of *'s like so:

*
***
*****

It needs to take a user inputted number and draw a pyramid like the above pyramid with the number of *'s in the base matching the user inputted number (i.e., user enters 10, so the triangle has 10 *'s in the base). I figured it would be best to first create a loop to draw out the correct number of *'s before trying to create another loop to draw out the correct number of spaces, to properly align the *'s into a triangle shape.

int width = 0;
int height = 0;
int i = 0;
int leafWidth = 0;

[Code] .....

View 7 Replies


ADVERTISEMENT

C# :: Upper Pyramid Is Working Fine But Lower Pyramid Executes Infinite

Feb 10, 2015

I need to print like below pattern.

1
121
12321
1234321
123454321
1234321
12321
121
1

I got the upper pattern but below pattern is not working it executes infinte loop, how to reslove this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ro {
class ro {
static void Main(string[] args) {
int numberoflayer = 5, Space, Number;

[Code] ....

View 1 Replies View Related

C++ :: Program To Display N Depth Pyramid

Feb 21, 2013

Write a program that displays n depth * pyramid.

For example,Input: 4
Output:
*
***
*****
*******

This is what i have so far but it not giving me what i want.

#include <iostream>
using namespace std;
int main() {
int star;
int count=1;
cout<<"Enter the number: ";
cin>>star;

[Code] ....

View 1 Replies View Related

C++ :: Star Pyramid Program - Adding Stars?

Sep 13, 2013

I have written a star pyramid program, it adds two stars at a time but I want to rewrite the program so the stars double each time.

#include<iostream>
using namespace std;
int main() {
int a = 0, b = 8;
for (int c = 1; c < 10; c++) {
for (int space = b; space > 0; space--)

[Code] ...

View 1 Replies View Related

Visual C++ :: Drawing Text On A Bitmap?

Oct 5, 2012

I wrote a simple clock that shows the time over bitmap as follows:

Code:
void CMyClock::OnPaint()
{
CRect rect;
GetClientRect(&rect);

[Code]....

Now I got rid off the white border but everytime I draw a text it write on top of the previous text so after few seconds everything is a mess and the time is no longer readable.

View 5 Replies View Related

Visual C++ :: MFC Coordinate System - Drawing Of Angles?

Oct 11, 2013

I am drawing in a simple (square) MFC window. I realize that (0,0) starts in the upper left hand corner. I wanted to see how MFC handled drawing of angles, so I use this code:

Code:
double CompassDegreesToRadians(double compassDegrees) {
return((PI / 2.0f) - (compassDegrees * PI / 180.0f));
}
// Make pen
CPen penRed;
penRed.CreatePen(PS_SOLID | PS_COSMETIC, 1, RGB(255, 0, 0));
// Test Angles

[Code] .....

Using this code, and changing the value of angle1 to these values (0, 90, 180, 270) I think MFC uses the coordinate system:

Code:
180 -y
|
|
-x 270---------------- 90 +x
|
|
0 +y

This seems like a strange coordinate system to use. Am I doing something wrong? If this is correct, how can I convert my calculations to this coordinate system? (compass degrees):

Code:
0 +y
|
|
-x 270---------------- 90 +x
|
|
180 -y

View 4 Replies View Related

Visual C++ :: Drawing A Rubber Band Rectangle

Jan 23, 2015

I am trying to draw a rubber band rectangle. I have got a following code from a site but its giving an error:

Code:
class CSampleView: Public CView{
...
public:
CrectTracker m_tracker;//Changed to CRectTracker
...
};

Secondly, in the constructor to initialize the object CRectTracker document class:

CSampleDoc :: CSampleDOC () {
// Initialize tracker position, size and style.
m_tracker.m_rect.SetRect (0, 0, 10, 10);
m_tracker.m_nStyle = CRectTracker :: resizeInside |
CRectTracker :: dottedLine;
}

The error is:

error C2065: 'm_tracker' : undeclared identifier

How to get rid of this error??

View 4 Replies View Related

Visual C++ :: Control For Owner-drawing Items With 1 Or 2 Columns?

Jan 22, 2014

I want to show a list of graphical items in 1 or 2 columns (user selected). I will draw the items (owner-draw). I tried many hours today to find a solution with clistctrl. Is it possible to make it with clistctrl?

View 14 Replies View Related

Visual C++ :: Drawing Analog Clock - Sleep Function

Jan 19, 2015

The question says: Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().

OK, I wrote below code. It is in its primary stages and has not been completed yet.

Code:
#include <GUI.h>
#include <time.h>
#include <iostream>
using namespace Graph_lib;
//---------------------------------
class Dynamic_clock : public Window {

[Code] .....

I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.

[URL] ....

View 14 Replies View Related

Visual C++ :: Drawing (radius Sized) Lines From Center To Boundary Of Circle

Feb 3, 2014

I am facing a programming logic problem. I want to draw radius sized lines from centre of circle to the circle boundary.

My code is:

int x1, y1, x2, y2, i, r, old_xc,old_yc, x,y;
int xc, yc;
x1=170;
y1=300;
x2=70;
y2=400;
pDC->Ellipse(x1,y1,x2,y2);

[Code] .....

The lines are touching the circle boudary at only start while the rest of lines are smaller and the shape is a triangle instead of a pie slice.

View 8 Replies View Related

Visual C++ :: Is It Worthwhile To Write ActiveX Module Dedicated To Drawing Charts

Oct 22, 2014

I know the user installation must involve some registry manipulations and some other trickery. But the ActiveX way seems to be more modular.

Is it worthwhile to separate the charting modules from the exe and make an activex dll for this purpose?

View 5 Replies View Related

Visual C++ :: Custom Control Library Design?

Mar 15, 2015

i want to design a custom control (Ui widget library) , this library can be used by any IDe developer to develop his UI.

how to design a custom control library and plug in.

View 11 Replies View Related

Visual C++ :: Custom Control And Vertical Scrollbar - Repaint?

Apr 8, 2015

I'm having a custom control and I added a vertical scroll bar to it. After scrolling down and then up what all controls are added are disappeared. Controls added are (checkboxes, editboxes, browse button).

Scroll works fine. Looks like painting problem but unable to resolve the issue.

code snippet:
void MyCustomControl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
int minpos, maxpos;
GetScrollRange(SB_VERT, &minpos, &maxpos);
maxpos = GetScrollLimit(SB_VERT);

[Code] ....

View 3 Replies View Related

C++ :: How To Make Custom Hotkey On Program Via INI File

May 4, 2012

I am trying to make a custom hotkey on my program via a ini file.

Code:
TCHAR KeyValue[32];
GetPrivateProfileString(("test"), ("test"), ("") ,KeyValue, 32, ("C: est.ini"));
if(GetAsyncKeyState (KeyValue)) // Hotkeys 0x60 VK_NUMPAD0 //Problem here
{
}

Code:
test.ini :
[test]
test=0x60

Error:
invalid conversion from `CHAR*' to `int'
initializing argument 1 of `SHORT GetAsyncKeyState(int)'

View 5 Replies View Related

C :: How To Make Custom Program For Packaging Multiple Files In One

Nov 5, 2014

I want to make a custom program for packaging multiple files in one. Not as complicated as ZLIB or others. Consider few files, XML, txt, JPG, OGG, I want them to be added in 1 file. Not visible not readable. Just a datafile. I have some ideas about creating some kind of indexing of the start byte, end byte of each file. But I am still way too far. Can you point me some direction at what should I stress in creating this software. It will be portable since I am planning to use stdlib, stdio only, maybe and string to recreate the filenames from the large chunk datafile.

View 2 Replies View Related

C# :: VS Express 2013 - Open TXT File With Custom EXE Program

Jul 13, 2014

I'm using Visual Studio Express 2013 to create a Windows program that will upgrade my micro-controller firmware. I have a .exe program to upgrade it. What I normally do is I drag and drop a .txt file on the .exe program and it will be done. I want to write a program that will do the exact same thing. Where when I click on a button, it will run the .exe program with the .txt file.

What I got so far is just run the .exe program when i press the button. I do not know how to write a code to let the .exe start with the .txt file. Here's what I got so far.

Process.Start(@"C:UsersJayDocumentsVisual Studio 2013ProjectsWindowsFormsApplication1BSL_FilesBSL ScripterBSL_Scripter.exe");

That line only manage to open up my .exe file. How do I make it run with the .txt at this location?

C:UsersJayDesktopBSL_FilesBSLSCRIPT.txt

View 2 Replies View Related

C++ :: Displaying Inverted Pyramid

Oct 7, 2013

The user will enter the number of '*'s on the 1st row (ntop) and then the number of rows forming the trapezoid (nrows). (using <iostream>, cout)

For instance, an inverted trapezoid with 7 '*"s in the 1st row and 3 rows forming the inverted trapezoid looks like:

for (i = nrows; i >= 1; i--) {
for (j = 0; j >= nrows; j++) {
cout << " ";
} for (k=ntop; k >= 2; k--) {
cout << "*";
} }

The output is just blank as of now.

View 3 Replies View Related

C++ :: How To Make Inverted Pyramid

Oct 4, 2013

I am new to C++ and I want to make an inverted pyramid so it follows the form of:

54321
x432x
xx3xx

or:

7654321
x65432x
xx543xx
xxx4xxx

The goal is to make it look like that pattern. The x's denote spaces. This is only for integers under 10.

#include<iostream>
using namespace std;
int main() {
int n,i,j;
cout << "Enter a positive odd number: ";
cin >> n;

[Code] ....

I am not sure how to add the spaces or make it subtract like the pattern.

View 7 Replies View Related

C/C++ :: ASCII Art For Different Triangles And Pyramid

Mar 15, 2015

I have to Write a program to produce that makes four triangles and a pyramid. I have to ask the user they height of the triangle and prevent the user from entering a height any larger than 25. It should look like this.

Enter the height of your triangle/pyramid: 3

***
**
*

*
**
***

*
**
***

***
**
*

*
***
*****

im having tourble with 3 and 4th and also pyramid.

HERES WHAT I HAVE SO FAR.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main () {
int input = 0;
cout << "Please enter the height of your triangle/pyramid: ";

[Code] .....

View 2 Replies View Related

C++ :: Pyramid Of Stars With Spaces

Mar 21, 2013

How to solve this (for cycle)?

View 12 Replies View Related

C# :: Logic For Building Numbers Pyramid?

Jan 7, 2012

Code:
1
121
12321
1234321
123454321 EDIT:
the above pyramid looks like a doom.i.e 1-5 will be in center.1-4(L)1-3(L)1-2(L)1(L) similarly 1-4(R) 1-3(R) 1-2(R) 1(R)

I'm partly successful in building the requirement of the program.but cant able to think the logic for the other half. how can i proceed.below is the code written in c#.

Code:
for (int i = 1; i <= 5; i++)
{
//int l = 1;

[Code]....

View 3 Replies View Related

C++ :: Drawing A Map - Tiling In SDL

Jan 18, 2013

I'm in the beginning stages of designing my first video game using SDL, and have run into a bit of an impasse. I attempt to draw the map using a simple tile function and nothing prints to the screen. I am going to attach the function itself.

bool Tile::draw_tiles ( void ) {
GV gv;

//Open the map
std::ifstream map ( "test.map" );
for ( int y = 0; y < GV::MAP_HEIGHT / 64; y++ ) {
for ( int x = 0; x < GV::MAP_WIDTH / 64; x++ ) {

[Code] ....

Extra notes:
1. Compiles fine.
2. No run time errors (this function returns true).
3. Apply surface is a function that takes an x and y value for position on the
map, an image, a screen to print it to, and a rectangle to cut out the image out of.
4. I did some bug testing and added another function to print the image SDLS_tiles by itself (its just a simple sprite map) after the map.close() function, and it worked fine.

View 1 Replies View Related

C++ :: How To Use Mouse In Drawing Shapes

May 3, 2013

i have to make an application called " paint " in c++ . It should facilitate user to draw different shapes using a mouse. Now the biggest hurdle i am facing is the usage of mouse .. what is the header file for usage of mouse ? i am using visual studio 2010 . the syntax is creating problems ..

View 1 Replies View Related

C++ :: MFC Drawing Circle Instead Of Square

Mar 11, 2014

Found a good beginner's tutorial to learn Visual C++: [URL] ....

How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.

The drawing code from the tutorial is below. How to substitute filled circles for filled squares.

Code:

// CSameGameView drawing
void CSameGameView::OnDraw(CDC* pDC){
// First get a pointer to the document
CSameGameDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(!pDoc)

[Code] ....

View 6 Replies View Related

C :: Drawing A Shape (Square) Into PGM Image

Nov 22, 2013

I'm doing a project and I need to draw a square into a pgm image if certain conditions are met, but I'm not sure how to draw the square into the image.

View 2 Replies View Related

C++ ::  Drawing Rectangular Prism OpenGL

Oct 10, 2013

I am supposed to create a class of rectangular prism in opengl. I am having touble in writing my "draw()" function.

I have searched the web, and lots of the sites have:

glBegin(GL_Quads);

glVertex3f(x,y,z);
glVertex3f(...);
glVertex3f(...);
glVertex3f(...);

3D coordinates for each face.

For my code, I am getting a value for lengths of x, y and z like "getXlength(x_length)" etc... I would like to know how I can use these values to draw the prism rather than giving values for each coordinates in each face.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved