1001. A+B Format (20)

简介: #include #include using namespace std;int main(){ long a, b; cin >> a >> b; long sum = a + b; if(sum...


#include <iostream>
#include <string>
using namespace std;

int main()
{
	long a, b;
	cin >> a >> b;
	long sum = a + b;

	if(sum < 0) {cout << '-'; sum = - sum;}
	string s = to_string(sum);
	for(int i = 0; i < s.length(); i++){
		cout << s[i];
		if((len - i - 1) % 3 == 0 && i != len - 1) cout << ',';
	}
	cout << endl;

	return 0;
}



目录
相关文章
|
5月前
DATE_FORMAT函数使用
DATE_FORMAT函数使用
240 0
|
5月前
|
Python
完美解决丨ValueError: time data ‘2018/12/24‘ does not match format ‘%Y/%m/%d‘
完美解决丨ValueError: time data ‘2018/12/24‘ does not match format ‘%Y/%m/%d‘
|
11月前
|
关系型数据库 MySQL PostgreSQL
PSQLException: 错误: 函数 date_format(timestamp without time zone, unknown) 不存在
PSQLException: 错误: 函数 date_format(timestamp without time zone, unknown) 不存在
287 0
|
SQL
format函数
format函数
138 0
|
SQL MySQL 关系型数据库
mysql DATE_FORMAT(date, format) 函数
DATE_FORMAT(date, format) 函数用法   DATE_FORMAT(date, format) 函数根据format字符串格式化date值。   1.把字符串转为日期格式 实例: SELECT DATE_FORMAT('2017-09-20 08:30:45', '%Y-...
3309 0
【转载】format的用法。
以前没太注意这个用法,到网上找一个,copy过来,方便以后的查看。   "I see stuff like {0,-8:G2} passed in as a format string. What exactly does that do?" -- Very Confused String Fo...
909 0