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语言 请多支教啊
大家用自己的办法也可以阿
注意 是菱形
(在这里打不住来,这里只能显示右对齐的)