[ create a new paste ] login | about

Link: http://codepad.org/BVCll4KX    [ raw code | output | fork ]

C++, pasted on Oct 29:
//seiseki.h
#ifndef INCLUDE_GUARD_SEISEKI
#define INCLUDE_GUARD_SEISEKI

class seiseki
{
public:
	seiseki(int kokugo, int suugaku, int english);
public:
	const int average;
};
#endif

// seiseki.cpp
// #include "seiseki.h"
seiseki::seiseki(int kokugo, int suugaku, int english)
  : average(static_cast<int>((kokugo + suugaku + english) / 3.0))
{

}

// main.cpp
// #include "seiseki.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void make_file(){
	ofstream fout;
	fout.open("test.dat");
	for (int i = 0; i < 10; i++) {
		fout << i << " " << 
			((i << 7) + i) % 100 << " " << 
			((i << 4) + i) % 100 << " " << 
			((i << 10) + i) % 100 << endl;
	}
}

int main(void)
{

	make_file();
	ifstream f;
	f.open("test.dat");
	for (int i = 0; i < 10; i++) {
		string name;
		int a, b, c;
		f >> name >> a >> b >> c;
		std::cout << name << "さんの平均点は" <<  seiseki(a, b, c).average << "です" <<endl;
	}

	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です
さんの平均点は41543211です


Create a new paste based on this one


Comments: