跪求大一C语言答案

可复制 可链接 谢谢 注意是大一C语言 不是C++ 完整点 能考的

一箭穿心代码
#include<graphics.h>
#include<math.h>

#define FNX(x1) (int)(x+(x1)*sl)
#define FNY(y1) (int)(MAXY-(y+(y1)*sl))
#define R(theta) 1-pow(cos(1*theta),1)

int sl=50,MAXY;
float x1,y1,xs,ys,r,theta;
/*画心*/
void draw(int x,int y)
{
for(theta=0;theta<2*3.14;theta+=0.01)
{r=R(theta);
x1=r*sin(theta);y1=r*cos(theta);
xs=FNX(x1);ys=FNY(y1);
if(theta==0)moveto(xs,ys);else lineto(xs,ys);
}
}

/*画箭头*/
void jian()
{
line(205,235,200,240);
line(200,240,205,245);
line(200,240,214,240);
line(400,240,500,240);
line(485,235,480,240);
line(480,240,485,245);
line(490,235,485,240);
line(485,240,490,245);
line(495,235,490,240);
line(490,240,495,245);
line(500,235,495,240);
line(495,240,500,245);
line(505,235,500,240);
line(500,240,505,245);
line(485,235,505,235);
line(485,245,505,245);
}
/*主程序*/
main()
{int driver=DETECT,mode;
initgraph(&driver,&mode,"");
setbkcolor(1);
setcolor(4);
MAXY=getmaxy();
draw(280,280);/*左心*/
draw(370,280);/*右心*/
jian();
getch();
closegraph();
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-08-20
题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。

1.程序分析:利用while语句,条件为输入的字符不为'\n'.

2.程序源代码:

#include "stdio.h"

main()

{char c;

int letters=0,space=0,digit=0,others=0;

printf("please input some characters\n");

while((c=getchar())!='\n')

{

if(c>='a'&&c<='z'||c>='A'&&c<='Z')

letters++;

else if(c==' ')

space++;

else if(c>='0'&&c<='9')

digit++;

else

others++;

}

printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,

space,digit,others);
相似回答