为什么爆0?

B2083 画矩形

@[Azure__](/user/565945) 人家用scanf![](//图.tk/j)
by Iwara_qwq @ 2022-07-08 14:56:55


``` #include <bits/stdc++.h> int i,j,k; char d; using namespace std; int main() { cin>>i>>j>>d>>k; for(int q=0; q<i; q++) { for(int y=0; y<j; y++) { if((q!=0)&&(q!=i-1)&&(y!=0)&&(y!=j-1)) cout<<(k==0?' ':d); else cout<<d; } printf("\n"); } return 0; } ``` 用cin,cout吧(
by Iwara_qwq @ 2022-07-08 15:00:12


@[wangzicheng2009](/user/575803) 输入换成 ```c scanf("%d%d %c%d",&i,&j,&d,&k); ``` 因为输入中j的后面有空格,直接赋值给了char类型的d,导致你的输出就变成了[空格][空格][空格][空格]......
by Brush @ 2022-07-08 17:01:46


万分感谢~~ 下学期初二
by wangzicheng2009 @ 2022-07-08 17:13:10


|