关于c语言的问题

Write a program that reads a character from keyboard and prints on the screen the approximate shape of a diamond using that character.
Write a function info that displays instructions to the user, reads a character value from the keyboard and returns that value to the calling function.
Write a function diamond that takes one parameter of the type char and prints on the screen the approximate shape of a diamond using the character provided as the actual parameter. For example if the character is A, the program should display:

A
AAA
AAAAA
AAAAAAA
AAAAA
AAA
A

The main program should call first the info function to instruct the user to input a character and read that character from the keyboard. The return value of the function should be passed as parameter to the second function diamond to print the diamond shape on the screen.

My program:
#include<stdio.h>
void diamond(char);
char info(void);
void main (char x)
{

info();
diamond(x);
}

void diamond(char x)
{

printf(" %s \n",x);
printf(" %s%s%s \n",x,x,x);
printf(" %s%s%s%s%s \n",x,x,x,x,x);
printf("%s%s%s%s%s%s%s\n",x,x,x,x,x,x,x);
printf(" %s%s%s%s%s \n",x,x,x,x,x);
printf(" %s%s%s \n",x,x,x);
printf(" %s \n",x);
}

char info()
{
char x[10];
printf("please type into a letter:");
scanf_s("%s",x);
return x[10];
}

小弟刚学c语言 请多支教啊
大家用自己的办法也可以阿
注意 是菱形
(在这里打不住来,这里只能显示右对齐的)

第1个回答  2008-10-09
不太懂你问什么,翻译?

从键盘输入字符,在显示器上显示输出形如菱形
编写两个函数,一个info,一个diamond
info:从键盘读取字符并返回函数值
diamond:通过x的传递输出以上输入的字符
x是数组,传递的是x[0]哦
相似回答