Sorry for easy questions....
#include <stdio.h>
int bs[200]={0}, gs[200]={0};
int n, k;
int i, j;
int main(void)
{
scanf("%d", &n);
scanf("%d",&k);
printf("%d", n);
for(i=1;i<=n;i++){
scanf("%d\n", &gs[i]);
}
for(i=1; i<=n; i++){
printf("%d %d\n", gs[i], i);
}
return 0;
}
Beginners make a lot of mistakes, so read the scanf function help carefully.
The link above explains it well.
If you insert a number and type enter, not only the number is stored in the buffer, but the enter key is also in the buffer.
In other words, if it is a consecutive scanf, the first number and the second number enter the value of the value.
To prevent this, you can empty the buffer.
Please call getchar after scanf.
© 2024 OneMinuteCode. All rights reserved.