70,038
社区成员
发帖
与我相关
我的任务
分享#include <stdio.h>
int side (int x);
char character(char t);
int main ()
{
int n;
char c;
printf("the number is :\n");
scanf("%d",&n);
printf("the char is:");//为什么执行程序时这两步没有
scanf("%c",&c);//作用?即没有打出the char is:和让我输入字符的过程
side(n);
character(c);
}
int side (int x){
int i=0,j;
for(i=0;i<x;i++){
for(j=0;j<x;j++){
printf("*");
}
printf("\n");
}
}
char character(char t)
{
printf("%c",t);
}
scanf(" %c",&c);printf("the number is :\n");等你输入了再执行printf("the char is:"); printf("the number is :\n");
scanf("%d",&n); /* 输入是以回车结束的 */
printf("the char is:");//为什么执行程序时这两步没有
fflush(stdin);
/* 接收一个字符,而如果不加fflush(stdin);清空缓存的话,此处接收的就是上一个scanf的回车符 */
scanf("%c",&c);//作用?即没有打出the char is:和让我输入字符的过程
side(n);
printf("the number is :\n");
scanf("%d",&n);
printf("the char is:");
fflush(stdin);
scanf("%c",&c);
side(n);
#include <stdio.h>
int side (int x);
char character(char t);
int main ()
{
int n;
char c;
printf("the number is :\n");
scanf("%d",&n);
getchar();//清除上面输入的回车键
printf("the char is:");//为什么执行程序时这两步没有
scanf("%c",&c);//作用?即没有打出the char is:和让我输入字符的过程
side(n);
character(c);
}
int side (int x){
int i=0,j;
for(i=0;i<x;i++){
for(j=0;j<x;j++){
printf("*");
}
printf("\n");
}
}
char character(char t)
{
printf("%c",t);
}