そういえばPythonにはswitch文が無いことに気づきました。
◆if文の書き方
if(a==1){
1番目の内容
}
else if (a==2){
2番目の内容
}
else {
2番目の内容
}
こんな感じ
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "整数を入力してください\n";
cin >> num;
if(num==1){
cout <<"1です";
}
else if (num==2){
cout <<"2です";
}
else {
cout <<"1でも2でもないです";
}
}
◆switch文の書き方
switch(a){
case 1;
(case1の内容)
break;
case 2;
(case2の内容)
break;
default;
break;
}
