资深天翼
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
using namespace std;
int main()
{
int a;
cin>>a;
cout<<"[1] apples"<<endl<<"[2] pears"<<endl<<"[3] oranges"<<endl<<"[4] grapes"<<endl<<"[0] Exit"<<endl;
if(a!=0){
if(a==1){
cout<<"price=3.0";
}
else if(a==2){
cout<<"price=2.5";
}
else if(a==3){
cout<<"price=4.5";
}
else if(a==4){
cout<<"price=9.5";
}else{
cout<<"price=0";
}
}
return 0;
}
别说是我教你的呀!
新手光能
定义 a;
输入>>a;
输出<<"[1] apples"<<endl;
输出<<"[2] pears"<<endl;
输出<<"[3] oranges"<<endl;
输出<<"[4] grapes"<<endl;
输出<<"[0] Exit";
if(a==1){
输出<<endl;
输出<<"price=";
printf("%.1f",3.00);
}else if(a==2){
输出<<endl;
输出<<"price=";
printf("%.1f",2.50);
}else if(a==3){
输出<<endl;
输出<<"price=";
printf("%.1f",4.50);
}else if(a==4){
输出<<endl;
输出<<"price=";
printf("%.1f",9.50);
}else{
输出<<endl;
输出<<"price=";
输出<<0;
}
望采纳,谢谢。
初级天翼
整形 a;
输出 "[1] apples" endl;
输出 "[2] pears" endl;
输出 "[3] oranges" endl;
输出 "[4] grapes" endl;
输出 "[0] Exit" endl;
输入 a;
如果 (a 等于 1){
输出 "price=";
printf("%.1f",3.00);
}否则 如果(a 等于 2){
输出 "price=";
printf("%.1f",2.50);
}否则 如果(a 等于 3){
输出 "price=";
printf("%.1f",4.50);
}否则 如果(a 等于 4){
输出 "price=";
printf("%.1f",9.50);
}否则 如果(a 等于 0){
exit(0);
}否则{
输出 "price=0";
}
缔造者
cout<<"[1] apples"<<endl<<"[2] pears"<<endl; cout<<"[3] oranges"<<endl<<"[4] grapes"<<endl; cout<<"[0] Exit"<<endl; cin>>a;
核心中的核心
初级天翼
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"[1] apples"<<endl;
cout<<"[2] pears"<<endl;
cout<<"[3] oranges"<<endl;
cout<<"[4] grapes"<<endl;
cout<<"[0] Exit"<<endl;
cin>>n;
switch(n){
case 0:
return 0;
case 1:
cout<<"price=3.0"<<endl;
return 0;
case 2:
cout<<"price=2.5"<<endl;
return 0;
case 3:
cout<<"price=4.5"<<endl;
return 0;
case 4:
cout<<"price=9.5"<<endl;
return 0;
default:
cout<<"price=0"<<endl;
}
return 0;
}