This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
void func(std::vector<int>::iterator begin, std::vector<int>::iterator end) | |
{ | |
while (++begin != end) { | |
std::cout << *begin << std::endl; | |
} | |
} | |
int main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cmath> | |
using namespace std; | |
//素数かどうかが真のものの数(カウントアップ)を返す | |
int countup(vector<bool>::iterator begin, vector<bool>::iterator end) | |
{ | |
int counter = 0; | |
while (begin++ != end) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
int countup_days(int m, int d) // m月d日が、1月1日から何日目か返す | |
{ | |
int sum = 0; | |
const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,}; | |
for (int i=1; i<m; i++) { | |
sum += month[i]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stack> | |
using namespace std; | |
int main() | |
{ | |
stack<int> stk; | |
int car; | |
while (cin >> car) { | |
if (car) { | |
stk.push(car); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ___Class_IntTwin | |
#define ___Class_IntTwin | |
#include <utility> | |
#include <algorithm> | |
class IntTwin | |
{ | |
int v1; | |
int v2; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ___Class_Counter | |
#define ___Class_Counter | |
#include <climits> | |
class Counter { // カウンタクラス | |
unsigned cnt; // カウンタ | |
public: | |
// 引数を渡すことなく呼び出せるデフォルトコンストラクタ | |
// カウンタを0にするためにデータメンバcntを0で初期化している | |
Counter() : cnt(0) { } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Time.h" | |
// クラスTimeのデフォルトコンストラクタ | |
Time::Time() | |
{ | |
h = 12; | |
m = s = 0; | |
} | |
// クラスTimeのコンストラクタ | |
Time::Time(int hh, int mm, int ss) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
int input; | |
vector<int> array; | |
for (int i=0; i<5; ++i) { | |
cin >> input; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vector (事前に個数のわからないデータの読み込み) | |
#include <vector> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
vector<int> x; | |
cout << "整数を入力せよ \n 終了は9999" << endl; | |
while (true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iomanip> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
vector<int> v; | |
cout << "要素数 容量" << endl; | |
for (vector<int>::size_type i = 0; i < 100; i++) { | |
v.push_back(i); |