結果

問題 No.784 「,(カンマ)」
ユーザー KuraKura
提出日時 2019-02-13 22:05:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 60,544 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 12:27:27
合計ジャッジ時間 1,237 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a;
	cin >> a;
	int b = 1;
	int c = a;
	for (;c>=1000;) {
		c /= 1000;
		b++;
	}
	vector<int> d(b);
	for (int i = 0; i < b; i++) {
		d[i] = a % 1000;
		a /= 1000;
	}
	for (int i = b-1; i >= 1; i--) {
		if (i!=b-1&&d[i] < 10) {
			cout << "00" << d[i] << ",";
		}else if (i != b - 1&&d[i] < 100) {
			cout << 0 << d[i] << ",";
		}else {
			cout << d[i] << ",";
		}
	}
	if (d[0] < 10) {
		cout << "00" << d[0] ;
	}
	else if (d[0] < 100) {
		cout << 0 << d[0];
	}
	else {
		cout << d[0]<<endl;
	}
}
0