ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 11718번,11719번,11720번
    백준알고리즘/입출력 2020. 10. 1. 22:34

    11718번

    #include<iostream>
    #include<string>
    using namespace std;
    int main(void)
    {
    	string str;
    	while (1)
    	{
    		getline(cin, str);
    		if (str == "\0")
    		{
    			break;
    		}
    		else
    		{
    			cout << str << endl;
    		}
    	}
    	
    	
    }

    11719번

    #include<iostream>
    #include<string>
    using namespace std;
    int main(void)
    {
    	int i = 1;
    	string str;
    	while (i<=100)
    	{
    		getline(cin, str);		
    		cout << str << endl;
    		i++;
    	}
    	
    	
    }

     

    11720번

    #include<iostream>
    #include<string>
    using namespace std;
    int main(void)
    {
    	int n = 0;
    	cin >> n;
    	char a;
    	int sum = 0;
    	for (int i = 0; i < n; i++)
    	{
    		cin >> a;
    		sum = sum + (a - 48);
    	}
    	cout << sum;
    }

     

    공백입출력 string,char

    #include<iostream>
    #include<string>
    using namespace std;
    int main(void)
    {
    	string a;
    	getline(cin, a);
    	cout << a << endl;
    
    	char b[100];
    	cin.getline(b, 100);
    	cout << b;
    
    }

    '백준알고리즘 > 입출력' 카테고리의 다른 글

    1924번  (0) 2020.10.02
    11721번,2741번,2742번,2739번  (0) 2020.10.02
    11022번  (0) 2020.10.01
    11021번  (0) 2020.10.01
    10953번  (0) 2020.10.01
Designed by Tistory.