"%s\n"有什么用?
#include <stdio.h>
int main()?
{
? ? int score = 7200;
? ? //完善一下代碼
? ? if(score >= 10000)
? ? {
? ? ? ? printf("%s\n","鉆石玩家");
? ? }
? ? else if(score >= 5000 && score <10000)
? ? {
? ? ? ? printf("%s\n","白金玩家");? ??
? ? }
? ? else if(score >= 1000 && score < 5000)
? ? {
? ? ? ? printf("%s\n","青銅玩家");? ? ?
? ? }
? ? else
? ? {
? ? ? ? printf("%s\n","普通玩家");? ??
? ? }
? ? return 0;
}
我寫的以上代碼和每一行去掉<“%s\n”,>運行結果是一樣的,但是為什么。
2025-10-28
看成兩部分,“%s”,"\n"。前者表示占個位子讓后面的字符串來填;后者表示換行。因此寫不寫都一樣