์ฝ๋์ (Code up) 1010~1027 (์ ์ถ๋ ฅ) [ C++, CPP ]
๋ฌธ์ ๋งํฌ :https://codeup.kr/problemsetsol.php?psid=23
๋ฌธ์ ์ง / ๊ธฐ์ด 100์
codeup.kr
*1010๋ฒ
#include <iostream>
using namespace std;
int main(){
int a;
cin >> a;
cout << a ;
}
*1011๋ฒ
#include <iostream>
using namespace std;
int main(){
char c;
cin >> c;
cout << c;
}
*1012๋ฒ
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
float n ;
cin >> n;
cout << fixed << setprecision(6) << n;
}
๊ธฐ๋ณธ์ ์ผ๋ก ์ซ์๋ฅผ ์ถ๋ ฅํ ๋ cout์ ์ ๋ฐ๋๋ 6์ด๋ค. (์ฆ, ์์ฒด์ ์ผ๋ก 6๊ฐ์ ์ซ์๋ฅผ ์ถ๋ ฅํ๋ค.)
ํ์ง๋ง ๋ฌธ์ ์์ ์ ์๋ ์์๋ 7์๋ฆฌ ์์ด๋ฏ๋ก ์ถ๋ ฅ์๋ฆฟ์ ์กฐ์ ์ด ํ์ํ๋ค. iomanipํค๋์ setprecision๊ธฐ๋ฅ์ ์ฌ์ฉํด์ผํ๋ค.
fixed์ setprecisino์ ๊ฐ์ด ์ฐ๊ฒ๋๋ฉด, ์์์ ๋ง n์๋ฆฌ์ ์ถ๋ ฅํฉ๋๋ค.
fixed๊ฐ ์๋ค๋ฉด, ์ ์์ ์์๋ถ๋ถ์ ํฉ์ณ์ n์๋ฆฌ์๋ก ์ถ๋ ฅํ๊ฒ ๋ฉ๋๋ค.
*1013๋ฒ
#include <iostream>
using namespace std;
int main(){
int a,b;
cin >>a >>b;
cout <<a<<" "<<b;
}
*1014๋ฒ
#include <iostream>
using namespace std;
int main(){
char a, b;
cin>>a>>b;
cout<<b<<" "<<a;
}
*1015๋ฒ
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
float a;
cin >> a;
cout << fixed << setprecision(2)<<a;
}
// fixed(์์์ ์ ๊ณ ์ ) + setprecision(2) = ์์์ ์๋ 2์๋ฆฌ๊น์ง ์ถ๋ ฅํ๋ค.
*1017๋ฒ
#include <iostream>
using namespace std;
int main(){
int n;
cin >> n;
cout << n<<" "<<n<<" "<<n;
}
*1018๋ฒ
#include <iostream>
using namespace std;
int main(){
int h, m;
scanf("%d:%d",&h,&m);
printf("%d:%d",h,m);
}
*1019๋ฒ
#include <iostream>
using namespace std;
int main(){
int y,m,d ;
scanf("%d.%d.%d",&y,&m,&d);
printf("%.4d.%.2d.%.2d",y,m,d);
}
*1020๋ฒ
#include <iostream>
using namespace std;
int main(){
int f,b;
scanf("%d-%d",&f,&b);
printf("%.6d%.7d",f,b);
}
*1021๋ฒ
#include <iostream>
#include <string>
using namespace std;
int main(){
string a;
cin >> a ;
cout << a;
}
*1022๋ฒ
#include <iostream>
using namespace std;
int main(){
char a[2000];
cin.getline(a,2000,'\n');
cout << a ;
}
*1023๋ฒ
#include <iostream>
using namespace std;
int main(){
int a,b;
scanf("%d.%d",&a,&b);
cout <<a << endl << b;
}
*1024๋ฒ
#include <iostream>
using namespace std;
int main(){
char a[21];
cin >> a ;
for(int i=0;a[i]!=0;i++){
cout<<"'" <<a[i]<<"'" <<endl;
}
}
*1025๋ฒ
#include <iostream>
using namespace std;
int main(){
int a,s,d,f,g;
scanf("%1d%1d%1d%1d%1d",&a,&s,&d,&f,&g);
printf("[%d0000]\n[%d000]\n[%d00]\n[%d0]\n[%d]\n",a,s,d,f,g);
}
*1026๋ฒ
#include <iostream>
using namespace std;
int main(){
int h,m,s;
scanf("%d:%d:%d",&h,&m,&s);
printf("%d",m);
}
*1027๋ฒ
#include <iostream>
using namespace std;
int main(){
int y,m,d;
scanf("%d.%d.%d",&y,&m,&d);
printf("%.2d-%.2d-%.4d",d,m,y);
}
*ํ์ด์ฌ ํ์ด๋ code up ์นดํ ๊ณ ๋ฆฌ์ ์์ต๋๋ค.