컴퓨터공부/알고리즘

알고리즘 문제 풀때, 파일 입출력으로 입출력하고 싶을 때

achivenKakao 2016. 11. 6. 00:39
각종 TC를 직접 손으로 집어 넣는 방법은... 시간이 많이 뺏긴다.
그래서 좀 찾아봤는데.. 분명 뭔가 있었던 것 같은데 못 찾았다..

그냥 구글링해서 대충 만들었는데.. 동작은 한다... 일단 이렇게 가야지..

+


// ConsoleApplication1.cpp : Defines the entry point for the console application.

//


#include "stdafx.h"

#include <iostream>

#include <fstream>      // std::ifstream


using namespace std;



int main()

{

std::ifstream cin("input.txt", ios::in);

std::ofstream cout("output.txt", ios::out);


int a; 


cin >> a;


cout << a;


cin.close();

cout.close();


return 0;

}

 






참고 : http://dmaxm11.tistory.com/41

코드 출처 : 나