c语言怎么用*输出字母H

Python033

c语言怎么用*输出字母H,第1张

#include<stdio.h>

#define N 7

#define M 4

void main() { int i,jchar c

for ( i=0i<Ni++ ) {

printf("*")

c=( i==N/2 )?('*'):(' ')for ( j=0j<Mj++ ) printf("%c",c)

printf("*\n")

}

}

#include<stdio.h>

int main()

{ int h,m,s

scanf("%d:%d:%d",&h,&m,&s)

printf("%02d:%02d:%02d\n",h,m,s)

return 0

}

一个.h文件

对应有一个.c文件,这样写助于查看和修改程序。比如a.h

a.c:

在.h文件中

#ifndef

__A_H_

#define

__A_H_

#include

void

trans2(double

B)

double

trans1()

#endif

在.c文件中

#include

"a.h"

把相应的函数定义写在.c文件中

再在main.c文件中

#include

"a.h"

#include

main()

{

double

trans1()

//由度分秒到弧度

{

double

B1,B11,B12,B13,B111

scanf("%lf°%lf′%lf″",&B11,&B12,&B13)

B111=fabs(B11)

//B11可能为负值

B1=B111+B12/60.0+B13/3600.0

B1=B1*atan(1)/45.0

if(B11<0)

B1=-B1

return

B1

}

void

trans2(double

B)

//由弧度到度分秒并输出角度值

{

int

a,b

double

B0

B0=fabs(B)

//B可能为负值

double

c

B0=B0*45.0/atan(1)

a=int(B0)

b=int((B0-a)*60)

c=(B0-a)*3600-b*60

if((int)(c)==60)

//为了避免出现59′60″这种情况,不过好像不起作用,不知道为什么,原来是int没有加括号

{

b=b+1

c=0.0

}

if(b==60)

{

b=0

a=a+1

}

if(B<0)

a=-a

printf("%d°%d′%.4f″\n",a,b,c)

}

}

就可以在main.c函数中调用a.c中的函数了