Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要读取 N 未知的数组中一行中的所有 N 个数字。当遇到换行符时,读取另一个数组中的下一个 X 数字。X 也是未知数。
输入格式为:-
1 2 3 4 5 .. 到 N(存储在数组 A 中)
1 2 3 4 .. 到 X(存储在数组 B 中)。
如何接受这种情况的输入?
你可以试试
while ( scanf(" %d%c", &num, &ch) == 2 ) { if ( ch =='\n') break; // to do :: store or whatever you want }
它一直读到换行。