Skip to content

Instantly share code, notes, and snippets.

View chomado's full-sized avatar
🎀
Working

ちょまど | Madoka Chiyoda chomado

🎀
Working
View GitHub Profile
#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()
{
@chomado
chomado / countup_primes.cpp
Created August 4, 2014 07:56
n(入力int)以下の素数がいくつあるかを出力する。 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp
#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) {
#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];
}
@chomado
chomado / 0013.cpp
Created August 4, 2014 08:41
[AOJ]行き止まりの道路に車が云々とかだけど要するにただのstack http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<int> stk;
int car;
while (cin >> car) {
if (car) {
stk.push(car);
@chomado
chomado / IntTwin.h
Last active August 29, 2015 14:04
クラステンプレートについて
#ifndef ___Class_IntTwin
#define ___Class_IntTwin
#include <utility>
#include <algorithm>
class IntTwin
{
int v1;
int v2;
public:
@chomado
chomado / Counter.h
Last active August 29, 2015 14:04
変換関数と演算子関数(写経p384)
#ifndef ___Class_Counter
#define ___Class_Counter
#include <climits>
class Counter { // カウンタクラス
unsigned cnt; // カウンタ
public:
// 引数を渡すことなく呼び出せるデフォルトコンストラクタ
// カウンタを0にするためにデータメンバcntを0で初期化している
Counter() : cnt(0) { }
#include "Time.h"
// クラスTimeのデフォルトコンストラクタ
Time::Time()
{
h = 12;
m = s = 0;
}
// クラスTimeのコンストラクタ
Time::Time(int hh, int mm, int ss)
{
@chomado
chomado / AOJ_0018.cpp
Last active August 29, 2015 14:04
[AOJ] 5つの整数を降順に表示する。問題: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0018
#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;
@chomado
chomado / vector.cpp
Created August 5, 2014 08:35
vector練習写経
// vector (事前に個数のわからないデータの読み込み)
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector<int> x;
cout << "整数を入力せよ \n 終了は9999" << endl;
while (true) {
@chomado
chomado / vector_capacity.cpp
Created August 6, 2014 02:17
ベクトルの要素数と容量の変化を確認
#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);