일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- WebProgramming
- beans
- Sort
- C
- CSS
- API
- JavaScript
- 윈도우즈
- System
- jsp
- 투자
- 포인터
- CLASS
- array
- java
- meta
- request
- algorithm
- 노드
- 자료구조
- windows
- query
- function
- Call-by-reference
- UTF-8
- HTML
- 악성코드
- Kafka
- c++
- OOP
Archives
- Today
- Total
hahahia
sstream 본문
/* 한 줄에 1 ~ 30개 까지 정수가 주어진다.
각각의 합을 해당 줄에 출력하시오. */
#include <sstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
stringstream ss;
char str[1000];
string s;
while(gets(str))
{
int sum = 0;
int temp;
s = string(str);
ss << s;
while(ss>>temp)
{
sum += temp;
}
ss.clear();
cout << sum << endl;
}
}
// 불특정한 개수의 데이터를 입력받고자 할 때 stirng으로 입력받은 뒤 stringstream을 이용해 연산을 합니다.
// 불특정한 개수의 데이터를 입력받고자 할 때 stirng으로 입력받은 뒤 stringstream을 이용해 연산을 합니다.
'Language > C++ STL' 카테고리의 다른 글
set (0) | 2012.03.24 |
---|---|
Vector assign (0) | 2012.03.24 |
vector (0) | 2012.03.24 |
cmath (0) | 2012.03.24 |
String Process (0) | 2012.03.24 |
Comments