請(qǐng)問(wèn)是哪里錯(cuò)了
請(qǐng)問(wèn)是哪里錯(cuò)了
#include <stdio.h>
int main()?
{
? ? int sale=120; //銷(xiāo)售業(yè)績(jī)?yōu)?20萬(wàn)
? ? int year=1; //剛剛進(jìn)入公司1年
? ? //完善代碼
? ??
? ? if(sale>100)
? ? {
? ? ? ? if(year>=2)
? ? ? ? {
? ? ? ? ? ? printf("%s\n","獲獎(jiǎng)!");
? ? ? ? }
? ? ? ? printf("%s\n","很遺憾,期望你再接再厲");
? ? }
? ??
? ??
? ? else
? ? {
? ? ? ? printf("%s\n","很遺憾,期望你再接再厲");
? ? }
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ? return 0;
}
2018-04-26
正解
#include <stdio.h>
int main()
{
??? int sale=120; //銷(xiāo)售業(yè)績(jī)?yōu)?20萬(wàn)
??? int year=1; //剛剛進(jìn)入公司1年
??? //完善代碼
???
??? if(sale>100)
??? {
??????? if(year>=2)
??????? {
??????????? printf("%s\n","獲獎(jiǎng)!");
??????? }
??????? else ? ?? //這別少了else,if和else是配套的
??????? printf("%s\n","很遺憾,期望你再接再厲");
??? }
???
???
??? else
??? {
??????? printf("%s\n","很遺憾,期望你再接再厲");
??? }
return 0;
}
/*少了一個(gè)else
咳,同學(xué)還有你的分號(hào)別打成中文,還有最好別搞這么多的括號(hào),會(huì)看的眼花,if后面如果只有一條語(yǔ)句可以不用括號(hào)*/
2018-04-25
if(sale > 100 && year>=2)? ? if(sale > 100) { if(year > =2){yes}else{no}}else{no}