猿问

scanf函数输入两次才能显示结果?

#include <stdio.h>

main()

{

int n=getchar();

int i;

int sum = 0;

scanf("%d", &n);

for (i = 0;  i <= n; i++) {

if (i % 2 == 1) { 

sum = sum + i; }

}

printf("%d\n", sum);

}


dd1231234044160
浏览 1682回答 3
3回答

望远

int n=getchar();直接把getchar()去掉int n;

慕的地8582982

UEBLZEEUORFHHNVJAJUOGNPILTTOLWFHAAZELCJCMLFTIHIYFOLNXKVOXQEJNDIMWRDWEVSFFVPFTYXYGWXGNNKWOEQQNEXUHLIFFBZHIRYRFJVOJCCTTTCZDOXTDXORBAYXMVGPAQLEGTHGFVZZXHKDBGNCVFFZIMCNPPJMVCMEBAOOAKOIYPPSRSCNBXXCGDKAAFPFYFGGXFYIZCBEIZFMDXRRJRVZQGKVSJNKJJTTOYIGKRRXTDQDYWZRESAZZZDMTANHOOSKKXXEEIYDLEVCJWYYOPKGVYPNHNMLSVUAAKDTFFCUTFWKLORFUBNOUBQQAQBOORBUKUYRANNUTBJEUPCMXHCDMCGXNSITDLMWCGNUATUXHBEKNHUDVJZBPXAQRZNWDQKHUHYDJPWHEVJTZCVWASTNBPGABLWWGEAIKBTMWJGNGJJHSBOBPOLZMKYQWFCTZGDXKREDOLICANXLODZWAXEBJCWDRFOGWTOVOREJPQBQXWQDNRMWSZLVSPZQXZYVIQWMSRVFGPSSJPXAUFJXQWQNKTUZMKTJGJGTGNREVAADBZNURRZMKYBLZUYXQNEKGGOYIRRUGXKQDDUQISIQNDGQGGVTKRECBJKRBYVOYVWLORPXTTHQOJEEZWQXXRUYTLTFJZWWUXEBVLLDULBVYBPYIZZNYYYBDVEHKKIIRWWADBMCTHFFBBFQIYSXLCLLVIKKAWQFFTTWJQAEEOIWCCVPCLDPFWWZLXBWOLYVMWWTTNHYGDGGOOLOXLPGZDUNXLKKCSLRYVSSYYZIFZWMDRUILYPVVBGUZMWMTXXBSJZKADCXAGNPGTEUUTKQSAGGFMMLKILTKCZMMMTGWQWUEFOYIOOPFEKQXNRULHAE

Will_木

用了n=getchar()和scanf("%d",&n) 就要输入两次咯
随时随地看视频慕课网APP
我要回答