查看: 1386|回复: 13
|
请问在C++里面我要弄一排字向右移动,coding是什么?
[复制链接]
|
|
请问在C++里面我要弄一排字向右移动,coding是什么? |
|
|
|
|
|
|
|
发表于 23-4-2007 05:44 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 26-4-2007 04:04 PM
|
显示全部楼层
原帖由 songpe 于 23-4-2007 05:44 PM 发表
不是很明白。
指的是右边对齐吗?
不是。我要的是不停的移动 |
|
|
|
|
|
|
|
发表于 26-4-2007 04:35 PM
|
显示全部楼层
C++ Code
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
//Wait() function form www.cplusplus.com
void wait ( float seconds )
{
float endwait;
endwait = clock () + seconds * 1000 ;
while (clock() < endwait) {}
}
//The C++ Code
int main ()
{
int x=1,n=0;
while(x!=0)//infinte loop
{
if(x==40)
{
x=0;
}
for(n=x;n>0;n--)
{
printf(" ");
}
x++;
printf("The Word You Want to Scroll.\n");
wait (0.01);
system("cls");
}
return 0;
}
[ 本帖最后由 CyySky 于 27-4-2007 06:26 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 27-4-2007 11:05 AM
|
显示全部楼层
我也来。。
#include <windows.h>
int main()
{
HWND myHandle;
SetConsoleTitle("aaa");
myHandle= FindWindow( NULL, "aaa" );
HDC hdc = GetDC(myHandle);
SetTextColor(hdc,0x00ff00);
SetBkColor(hdc,0x00);
unsigned short int tx=0xff,ty=0x60;
LPCTSTR t=" Whatever text";
for(unsigned short int i=0x00;i<0xff;i++)
{
unsigned short int vx=i*2;
TextOut(hdc,tx+vx,ty,t,strlen(t));
_sleep(10);
i=(i>98)?SetTextColor(hdc,0x00),
TextOut(hdc,tx+vx,ty,t,strlen(t)),
SetTextColor(hdc,0xff<<(i%3)),
i=0:i;
}
ReleaseDC(myHandle, hdc);
return 0;
}
[ 本帖最后由 tensaix2j 于 27-4-2007 08:17 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 27-4-2007 07:54 PM
|
显示全部楼层
再来一个比较疯狂的。。
#include <windows.h>
#include <cmath>
void m(int *x,int *y ,float r)
{
float //mparams
c1=.1, d1=.05,
c2=.25, d2=.24,
c3=1.6, d3=.24,
c4=300, d4=200,
c5=300, d5=200;
*x=sin(r*c1+2*c2+c3)*c4+c5;
*y=cos(r*d1+2*d2+d3)*d4+d5;
}
int main()
{
HWND myHandle;
SetConsoleTitle("aaa");
myHandle= FindWindow( NULL, "aaa");
HDC hdc = GetDC(myHandle);
SetTextColor(hdc,0x00ff00);
SetBkColor(hdc,0x00);
unsigned short int tx=0xff,ty=0x60;
LPCTSTR t=" Whatever text";
float r=0;
int x,y;
while(1)
{
m(&x,&y,r);
TextOut(hdc,x,y,t,strlen(t));
_sleep(10);
r+=1;
}
ReleaseDC(myHandle, hdc);
return 0;
}
[ 本帖最后由 tensaix2j 于 27-4-2007 10:55 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:03 AM
|
显示全部楼层
You have been hired by Happy Go Lucky Message Board System Sdn. Bhd. to
write a prototype for the program to drive their latest message board system.
Happy Go Lucky Message Board System Sdn. Bhd. is a company specializing
in manufacturing state of the art message board systems. Their latest message
board system is going to be used in all football stadium during the 2008 UEFA
EURO 2008 championship that will be held in Austria, Switzerland, next year.
The new message board uses an advanced technology and the company is very
secretive on its design and capability. Because of this you will not be able to test
your program on the real hardware. To aid you in developing the program they
give you a simulator for the message board display (display.zip).
The company is asking you to write a program that will read one or more
messages and the instruction on how the messages is to be animated (left to right,
top to bottom, etc) on the display board from an input file.
The simulator (display.zip) is very primitive in that the only drawing operation
that it support is the drawing of a dot in the message board area. Using thislibrary you are expected to come up with an ADT that provides a more high level
instruction, for example draw text, line, circle, etc.
The format of the input file is given below:
ACTION
ANIMATION+
TEXT+
RUN
[REPEAT]
DISPLAY+
BLINK*
WAIT*
RUN
REPEAT
SHOW+
[WAIT]
The meaning of the input format is as follows:
1. An input file contains exactly one ACTION
2. An ACTION contains one or more ANIMATION entries, and exactly one
RUN entry.
3. An ANIMATION contains one or more TEXT entry, and exactly one RUN
entry
4. The RUN entry for an ANIMATION contains the following entries:
(a) An optional REPEAT entry
(b) One or more DISPLAY entry
(c) Zero or more BLINK entry
(d) Zero or more WAIT entry
5. The RUN entry for an ACTION contains the following entries:
(a) Exactly one REPEAT entry, consisting of the following sub-entry:
i. One or more SHOW entry, consisting of the following sub-entry:
ii. An optional WAIT entry after each SHOW entry.
The company gives you a sample input file that conforms to the format above
(see the file input.txt).
The company expect you to come up with a demonstration input file that when
run with the program that you wrote, will show all the features that you have
implemented. |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:04 AM
|
显示全部楼层
这是input file
<action>
<animation name="Introduction">
<text name="intro" value="Hello World"/>
<run>
<display text="intro" color="black" effect="bottom-to-top"/>
</run>
</animation>
<animation name="McDonald's">
<text name="title" value="McDonalds..."/>
<text name="phrase" value="Serving the world one burger at a time."/>
<run>
<display text="title" color="blue" effect="fade-in"/>
<blink count="3" interval="100"/>
<wait duration="1000"/>
<display text="phrase" color="255,100,50" effect="left-to-right"/>
</run>
</animation>
<animation name="Kentucky Fried Chicken">
<text name="kfc1" value="KFC - Finger Licking Good!"/>
<text name="kfc2" value="We've got all your chicken needs covered!"/>
<run>
<repeat frequency="3">
<display text="kfc1" color="red" effect="left-to-right"/>
<wait duration="500"/>
<display text="kfc2" color="green" effect="top-to-bottom"/>
<wait duration="500"/>
</repeat>
</run>
</animation>
<run>
<repeat frequency="1">
<show animation="Introduction"/>
<wait duration="2000"/>
<show animation="Kentucky Fried Chicken"/>
<show animation="McDonald's"/>
</repeat>
</run>
</action> |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:04 AM
|
显示全部楼层
请问各位大大要怎样做?
[ 本帖最后由 L3MoN_TeA 于 28-4-2007 06:06 AM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:07 AM
|
显示全部楼层
帮帮忙啊,谢谢你们了!!!
[ 本帖最后由 L3MoN_TeA 于 28-4-2007 06:09 AM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:31 AM
|
显示全部楼层
output 大概要这样
 |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 06:33 AM
|
显示全部楼层
这是Canvas.h
#if !defined(CANVAS_H)
#define CANVAS_H
/* The canvas class.
* - Canvas coordinates starts from (0,0).
* - Origin is located at the top left corner of the canvas area.
* - Positive x-direction is to the right
* - Positive y-direction is down
* Example usage:
#include <cstdlib>
#include "canvas.h"
int main(void) {
Canvas c(); // Setup a canvas with the default values:
// 50x50 squares, each square is 10x10 pixels
c.dot(3,3); // Fills square (3,3) with black
c.use_color(RED);
c.dot(5,6); // Fills square (5,6) with RED
c.dot(5,7); // Fills square (5,7) with RED
c.use_color(COLOR(255, 0, 0)); // Another method of specifying the color RED
System("pause");
return 0;
}
*/
#include <iostream>
#include <cstdlib>
#include "graphics.h"
using namespace std;
class Canvas {
public:
/** Canvas: Constructor
* - witdth and height must be greater than 0, default is 50x50.
* - show_grid: If set to true, the canvas will have a checkerboard
* pattern as a guide for your drawing (this will slow down the
* drawing).
* - grid_size: Determines the size of one grid, default grid size is
* 10x10 pixels.
*/
Canvas(int width=50,
int height=50,
bool show_grid=true,
int grid_size=10,
int fgcolor=BLACK,
int bgcolor=WHITE);
/** Clears the canvas area of any drawing, sets the background to bgcolor */
void clear(void);
/** Sets the color to be used for drawing
* value for new_color can be:
* BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
* LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW
* and WHITE
*
* OR
*
* Using the RGB components:
* COLOR(255, 0, 0) for red
* COLOR(0, 255, 0) for green,
* COLOR(0, 0, 255) for blue, etc
*
* e.g: use_color(BLUE) OR use_color(COLOR(0,0,255));
*/
void use_color(int new_color);
/** Returns the current color */
int get_current_color(void);
/** Fills up the grid (x,y) of the canvas, using the current color */
void dot(int x, int y);
/** Returns the width */
int get_width(void);
/** Returns the height */
int get_height(void);
/** Destructor. Destroys the canvas window */
~Canvas();
private:
/** Draws the checkerboard grid on the canvas */
void draw_grid(int bgcolor=WHITE);
int width;
int height;
int size;
int pen_color;
int fgcolor;
int bgcolor;
int maxx, maxy;
static int instance_count;
bool show_grid;
};
#endif |
|
|
|
|
|
|
|
发表于 28-4-2007 03:55 PM
|
显示全部楼层
不是吧。 。。还用bgi..为何不用gdi呢?。。。 |
|
|
|
|
|
|
|

楼主 |
发表于 28-4-2007 05:31 PM
|
显示全部楼层
原帖由 tensaix2j 于 28-4-2007 03:55 PM 发表
不是吧。 。。还用bgi..为何不用gdi呢?。。。
学校要我做的,你可以教我吗?
[ 本帖最后由 L3MoN_TeA 于 28-4-2007 06:29 PM 编辑 ] |
|
|
|
|
|
|
| |
本周最热论坛帖子
|