백준알고리즘/입출력
11721번,2741번,2742번,2739번
풀스택 개발자
2020. 10. 2. 13:22
11721번
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string s;
getline(cin, s);
for (int i = 0; i < s.size(); i++)
{
cout << s[i];
if ((i+1) % 10 == 0)
{
cout << endl;
}
}
}
2741번
#include<iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
for (int i = 0; i < n; i++)
{
cout << i + 1 << '\n';
}
}
2741번 문제에서 칸을 띄울때 endl을 사용하면 시간초과가 나온다 하지만 '\n' 을 사용하면 타임리밋이 발생하지않음
2742번
#include<iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
for (int i = n; i > 0; i--)
{
cout << i << '\n';
}
}
2739번
#include<iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
for (int i = 1; i < 10; i++)
{
cout << n << ' ' << '*' << ' ' << i << ' ' << '=' << ' ' << n * i << '\n';
}
}