scanf()的读入

#include<cstdio>
#include<cstring>
int main()
{
    int a[10];
    memset(a, 0, sizeof(a));
    for(int i = 0; i < 5; i++)
        scanf(" %d", &a[i]);
    for(int i = 0; i < 5; i++)
        printf("%d ", a[i]);
}

 在scanf中%d前有一空格,会略去空格输入,直至数字读入。

posted on 2022-04-23 11:08  我欲  阅读(70)  评论(0)    收藏  举报