トピックス:while, for, 繰り返し, フィボナッチ数列, 九九の表, プログラミング, c
C プログラミング入門 (スライド資料とプログラム例)(Visual Studio 2019 を使用)(全15回)
https://www.kkaneko.jp/pro/adp/index.html
金子邦彦研究室ホームページ
https://www.kkaneko.jp/index.html
トピックス:while, for, 繰り返し, フィボナッチ数列, 九九の表, プログラミング, c
C プログラミング入門 (スライド資料とプログラム例)(Visual Studio 2019 を使用)(全15回)
https://www.kkaneko.jp/pro/adp/index.html
金子邦彦研究室ホームページ
https://www.kkaneko.jp/index.html
10. #include<iostream>
using namespace std;
int main(){
int A, B;
cin >> A >> B ;
int x = (A+1) * B;
int y = A * (B+1);
練習問題:AtCoder Beginner Contest 031 A
解法1
攻撃力を1増やす場合と防御力を1増やす場合を両方試し
てみて、大きい方を出力する
if(x > y){
cout << x << endl;
}
else{
cout << y << endl;
}
return 0;
}
11. #include<iostream>
using namespace std;
int main(){
int A, B;
cin >> A >> B;
練習問題:AtCoder Beginner Contest 031 A
解法2
レベルアップ前の値のうち、小さい方を1増やす
if(A < B){
cout << (A+1) * B << endl;
}
else{
cout << A * (B+1) << endl;
}
return 0;
}
24. while文とfor文の違い
while(条件式){
実行文
}
for( 初め ; 条件式 ; 毎回最後){
実行文
}
int i = 1;
int x = 0;
while( i <= 10 ){
x = x + i ;
i++;
}
int i;
int x = 0;
for( i = 1 ; i <= 10 ; i++ ){
x = x + i ;
}
25. 練習問題:NからMまでの偶数を小さい順に出力せよ
コンパイル方法
$ g++ pra.cpp
$ ./a.out プログラムを
書いている
ファイルの名前
#include<iostream>
using namespace std;
int main(){
int N, M;
cin >> N >> M ;
return 0;
}
ここに書く!!
例
入力:1 10
出力:2
4
6
8
10