㈠ 用c语言编写输出金字塔状的三行星号,怎么做
可通过for语句编写输出金字塔状的三行星号。具体步骤如下。
1、打开visual C++ 6.0,打开文件-新建-文件-C++ Source File。
㈡ C语言中星号居中输出方法问题
#include<iostream>
usingnamespacestd;
intmain()
{
inti,j,n=6;
for(i=1;i<=n;++i)//一共要输出n行
{
//输出第i行
for(j=1;j<=n-i;++j)//输出n-i个空格
cout<<"";
for(j=1;j<=2*i-1;++j)//输出2*i-1个星号
cout<<"*";
cout<<endl;
}
return0;
}
运行结果如下图,需要输出更多,请将n=6修改成自己希望的值。
㈢ C语言如何用星号*输出文字
printf("!!!!!!!!!!")
㈣ c语言汉字如何转换星号,比如:张三,用星号表示
程序如下:另外
除填空
,
本身就有问题
,下面已经
全部更改
#include
<stdio.h>
void
rcpchar(int
n,char
ch)
{
int
i;
for(i=0;
i<n;i++)
putchar(ch);
return;
}
void
main
()
{
int
r,star,space;
for(r=6;r>=1;r--)
{
space
=6-r;
rcpchar(space,'
');
star
=
r*2-1;
rcpchar(star,'*');
rcpchar(1,'\n');
}
}
------------------c++部落------------hello
word!--------
无论你是初学者还是专家,只要你热爱编程、交流、分享,欢迎加入
㈤ c语言输出星号是什么意思
#include<stdio.h>
main()
{ int N,a;
scanf("%d",&N);
for(a=0;a<N;a++)
printf("*");
getch();
}
这么写就行了,你前面有很多没用的还有些是程序布恩那个运行的
㈥ 急~关于C语言课程设计用星号构成A~Z字母输出~~~!!!
/* 第一题 */
#include <stdio.h>
#include <string.h>
#define SCREEN_COLS 80 /* how many columns does terminal have */
#define HORIZONTAL_DISTANCE 4 /* horizontal distance between two characters (列距) */
#define VERTICAL_DISTANCE 1 /* vertical distance between two rows of characters (行距) */
#define BRUSH_CHAR ('*')
#define BLANK_CHAR (' ')
/* ASCII_TAB字模中字体的高度和宽度 */
#define FONT_ROWS 7
#define FONT_COLS 5
/* 屏幕每行最多可以显示的字符个数 */
#define CHAR_PER_LINE (SCREEN_COLS/(FONT_COLS + HORIZONTAL_DISTANCE))
// ASCII_TAB[] contains all ASCII characters from sp (32) to z (122)
static const unsigned char ASCII_TAB[][5]= //5*7
{
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp
{ 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !
{ 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
{ 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #
{ 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $
{ 0xc4, 0xc8, 0x10, 0x26, 0x46 }, // %
{ 0x36, 0x49, 0x55, 0x22, 0x50 }, // &
{ 0x00, 0x05, 0x03, 0x00, 0x00 }, // '
{ 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (
{ 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )
{ 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *
{ 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
{ 0x00, 0x00, 0x50, 0x30, 0x00 }, // ,
{ 0x10, 0x10, 0x10, 0x10, 0x10 }, // -
{ 0x00, 0x60, 0x60, 0x00, 0x00 }, // .
{ 0x20, 0x10, 0x08, 0x04, 0x02 }, // /
{ 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0
{ 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
{ 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
{ 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
{ 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
{ 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
{ 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
{ 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
{ 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
{ 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
{ 0x00, 0x36, 0x36, 0x00, 0x00 }, // :
{ 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;
{ 0x08, 0x14, 0x22, 0x41, 0x00 }, // <
{ 0x14, 0x14, 0x14, 0x14, 0x14 }, // =
{ 0x00, 0x41, 0x22, 0x14, 0x08 }, // >
{ 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?
{ 0x32, 0x49, 0x59, 0x51, 0x3E }, // @
{ 0x7E, 0x11, 0x11, 0x11, 0x7E }, // A
{ 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
{ 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C
{ 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D
{ 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E
{ 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F
{ 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G
{ 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H
{ 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I
{ 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J
{ 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K
{ 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L
{ 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M
{ 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N
{ 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O
{ 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P
{ 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q
{ 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R
{ 0x46, 0x49, 0x49, 0x49, 0x31 }, // S
{ 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T
{ 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U
{ 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V
{ 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W
{ 0x63, 0x14, 0x08, 0x14, 0x63 }, // X
{ 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
{ 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z
{ 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [
{ 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // '\'
{ 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]
{ 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^
{ 0x40, 0x40, 0x40, 0x40, 0x40 }, // _
{ 0x00, 0x01, 0x02, 0x04, 0x00 }, // '
{ 0x20, 0x54, 0x54, 0x54, 0x78 }, // a
{ 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b
{ 0x38, 0x44, 0x44, 0x44, 0x20 }, // c
{ 0x38, 0x44, 0x44, 0x48, 0x7F }, // d
{ 0x38, 0x54, 0x54, 0x54, 0x18 }, // e
{ 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f
{ 0x0C, 0x52, 0x52, 0x52, 0x3E }, // g
{ 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h
{ 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i
{ 0x20, 0x40, 0x44, 0x3D, 0x00 }, // j
{ 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k
{ 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l
{ 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m
{ 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n
{ 0x38, 0x44, 0x44, 0x44, 0x38 }, // o
{ 0x7C, 0x14, 0x14, 0x14, 0x08 }, // p
{ 0x08, 0x14, 0x14, 0x18, 0x7C }, // q
{ 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r
{ 0x48, 0x54, 0x54, 0x54, 0x20 }, // s
{ 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t
{ 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u
{ 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v
{ 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w
{ 0x44, 0x28, 0x10, 0x28, 0x44 }, // x
{ 0x0C, 0x50, 0x50, 0x50, 0x3C }, // y
{ 0x44, 0x64, 0x54, 0x4C, 0x44 } // z
};
static char get_char_xy(char ch, int x, int y)
{
if (ch < ' ' || ch > 'z')
ch = ' ';
ch -= ' ';
return (ASCII_TAB[ch][x] & (1<<y)) ? BRUSH_CHAR : BLANK_CHAR;
}
static void print_row(char ch, int row)
{
int i;
for (i = 0; i < FONT_COLS; i++) {
printf("%c", get_char_xy(ch, i, row));
}
}
int main(int argc, char *argv[])
{
char str[80] = { '\0' };
int i, j, k, len, index = 0;
printf("Please input a string:\n");
scanf("%s", str);
len = strlen(str);
while (index < len) {
for (i = 0; i < FONT_ROWS; i++) {
for (j = 0; j < CHAR_PER_LINE && j + index < len; j++) {
print_row(str[index + j], i);
for (k = 0; k < HORIZONTAL_DISTANCE; k++) {
printf("%c", BLANK_CHAR);
}
}
printf("\n");
}
index += CHAR_PER_LINE;
for (k = 0; k < VERTICAL_DISTANCE; k++) {
printf("\n");
}
}
return 0;
}
/* 第二题 */
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MIN_POINT_NUMBER 3
#define MAX_POINT_NUMBER 100
#define MAX_POINT_COORD 1000.0
typedef struct Point_ {
float x;
float y;
} Point;
typedef struct Circle_ {
Point o; /* centre */
Point p1;
Point p2;
float r; /* radius */
} Circle;
typedef struct {
Point p;
int included;
} Element;
/* return squared distance of points a & b */
#define SQUARE(a) ((a)*(a))
#define SQUARED_DISTANCE(a,b) (SQUARE((a).x-(b).x) + SQUARE((a).y-(b).y))
#define DISTANCE(a,b) (sqrt(SQUARED_DISTANCE((a),(b))))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define EQUAL_FLOAT(a,b) (fabs((a)-(b)) < 0.00001)
/* get the circumcircle of a triangle */
static Circle
get_circumcircle(Point a, Point b, Point c)
{
Circle result;
float dx1 = a.x - b.x;
float dx2 = b.x - c.x;
float dy1 = a.y - b.y;
float dy2 = b.y - c.y;
float x1 = (a.x + b.x) / 2.0;
float x2 = (b.x + c.x) / 2.0;
float y1 = (a.y + b.y) / 2.0;
float y2 = (b.y + c.y) / 2.0;
result.o.x = ((dy1*dy2*(y2-y1) + x2*dx2*dy1 - x1*dx1*dy2)) / \
(dx2*dy1 - dx1*dy2);
result.o.y = ((dx1*dx2*(x2-x1) + y2*dy2*dx1 - y1*dy1*dx2)) / \
(dy2*dx1 - dy1*dx2);
result.r = DISTANCE(result.o, a);
result.p1 = a;
result.p2 = c;
return result;
}
/* get the mininal circle that includes three given points
* Note:
* 1) the tree points may be in one line
* or
* 2) the tree points make up a triangle
*/
static Circle
get_min_circle(Point a, Point b, Point c)
{
Circle result;
float ab,bc,ac, max;
ab = DISTANCE(a,b);
bc = DISTANCE(b,c);
ac = DISTANCE(a,c);
max = MAX(ab, MAX(bc,ac));
printf("[%f, %f]\n[%f, %f]\n[%f, %f]\n",a.x,a.y,b.x,b.y,c.x,c.y);
if (EQUAL_FLOAT(max*2, ab+bc+ac)) { /* in the same line */
printf("line\n");
if (EQUAL_FLOAT(max, ab)) {
/* ab is the diameter */
result.o.x = (a.x + b.x) / 2.0;
result.o.y = (a.y + b.y) / 2.0;
result.r = max / 2.0;
result.p1 = a;
result.p2 = b;
} else if (EQUAL_FLOAT(max, bc)) {
/* bc is the diameter */
result.o.x = (b.x + c.x) / 2.0;
result.o.y = (b.y + c.y) / 2.0;
result.r = max / 2.0;
result.p1 = b;
result.p2 = c;
} else {
/* ac is the diameter */
result.o.x = (a.x + c.x) / 2.0;
result.o.y = (a.y + c.y) / 2.0;
result.r = max / 2.0;
result.p1 = a;
result.p2 = c;
}
} else { /* triangle */
/* get the circumcircle of the triangle */
printf("triangle\n");
result = get_circumcircle(a, b, c);
}
printf("The circle's center is [%f, %f], radius is %f\n",
result.o.x, result.o.y, result.r);
return result;
}
int
main(int argc, char *argv[])
{
Circle circle;
Element *elements;
int n = 0, i;
while (n < MIN_POINT_NUMBER || n > MAX_POINT_NUMBER) {
printf("Please input point number (3-100):\n");
scanf("%d", &n);
}
elements = (Element*)malloc(sizeof(Element)*n);
memset(elements, 0, sizeof(Element)*n);
for (i = 0; i < n; i++) {
printf("Please input point (%d in %d):\n", i+1, n);
scanf("%f %f", &elements[i].p.x, &elements[i].p.y);
}
elements[0].included = 1;
elements[1].included = 1;
elements[2].included = 1;
circle = get_min_circle(elements[0].p, elements[1].p, elements[2].p);
for (i = 0; i < n; i++) {
if (elements[i].included)
continue;
if (DISTANCE(elements[i].p, circle.o) - circle.r > 0.00001) {
circle = get_min_circle(circle.p1, circle.p2, elements[i].p);
}
elements[i].included = 1;
}
return 0;
}
㈦ 关于C语言,如何用星号(*)打出名字,即星号的形状为名字的一笔一划(名字是指定的几个字)
首先你要设计一下一个字所占的行列数,在根据这个字的笔画在每一行里打印相对应的空格和* 重复执行printf()就可以实现了
㈧ 如何用C语言输出星号
输出星号,主要是锻炼我们使用循环语句的能力。根据图形的规律,研究出循环方法和控制条件,进而编写代码,输出结果,参考代码和运行结果如下:
本代码,可以输出任意高度的图形
do
{}
while();循环是用来控制测试笔数的,当输入数值小于等于0时,结束测试
㈨ c语言中的星号“*”
这意味着我要定义一个指针,*未定义时,获取以下地址的内容,输入方法。
1.打开visualc++6.0-File-新建的-File-c++源文件,如下图所示: