一、b1021
#include <cstdio>
#include <cstring>
int main(){
char n[1010];
int a[15] = {0};
int len;
scanf("%s", n);
len = strlen(n);
for(int i = 0; i < len; i++){
a[n[i] - 48] ++;
}
for(int i = 0; i < 10; i++){
if(a[i] != 0){
printf("%d:%d\n", i, a[i]);
}
}
return 0;
}
二、b1022
#include <cstdio>
int main(){
int a, b, d;
scanf("%d%d%d", &a, &b, &d);
int sum = a + b;
int ans[31], num = 0;
do{
ans[num++] = sum % d;
sum /= d;
}
while(sum != 0);
for(int i = num - 1; i >= 0; i--){
printf("%d", ans[i]);
}
return 0;
}
三、b1023
#include <cstdio>
int a[15];
int main(){
for(int i = 0; i < 10; i++){
scanf("%d", &a[i]);
}
for(int i = 1; i < 10; i++){
if(a[i] != 0){
printf("%d", i);
a[i]--;
break;
}
}
for(int i = 0; i < 10; i++){
for(int j = 0; j < a[i]; j++){
printf("%d", i);
}
}
return 0;
}
四、1024
#include <cstdio>
#include <cstring>
int main(){
char str[10010];
gets(str);
int len = strlen(str);
if(str[0] == '-'){
printf("-");
}
int pos = 0;
while(str[pos] != 'E'){
pos++;
}
int exp = 0;
for(int i = pos + 2; i < len; i++){
exp = exp * 10 + (str[i] - '0');
}
if(exp == 0){
for(int i = 1; i < pos; i++){
printf("%c", str[i]);
}
}
if(str[pos + 1] == '-'){
printf("0.");
for(int i = 0; i < exp -1; i++){
printf("0");
}
printf("%c", str[1]);
for(int i = 3; i < pos; i++){
printf("%c", str[i]);
}
}
else{
for(int i = 1; i < pos; i++){
if(str[i] == '.'){
continue;
}
printf("%c", str[i]);
if(i == exp + 2 && pos - 3 != exp){
printf(".");
}
}
for(int i = 0; i < exp - (pos - 3); i++){
printf("0");
}
}
return 0;
}
五、b1025
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 100010;
struct Node{
int address, data, next;
int order;
}node[maxn];
bool cmp(Node a, Node b){
return a.order < b.order;
}
int main(){
for(int i = 0; i < maxn; i++){
node[i].order = maxn;
}
int begin, n, K, address;
scanf("%d%d%d", &begin, &n, &K);
for(int i = 0; i < n; i++){
scanf("%d", &address);
scanf("%d%d", &node[address].data, &node[address].next);
node[address].address = address;
}
int p = begin, count = 0;
while(p != -1){
node[p].order = count++;
p = node[p].next;
}
sort(node, node + maxn, cmp);
n = count;
for(int i = 0; i < n / K; i++){
for(int j = (i + 1) * K - 1; j > i * K; j--){
printf("%05d %d %05d\n", node[j].address, node[j].data, node[j-1].address);
}
printf("%05d %d ", node[i * K].address, node[i * K].data);
if(i < n / K - 1){
printf("%05d\n", node[(i + 2) * K - 1].address);
}
else{
if(n % K == 0){
printf("-1\n");
}
else{
printf("%05d\n", node[(i + 1) * K].address);
for(int i = n / K * K; i < n; i++){
printf("%05d %d ", node[i].address, node[i].data);
if(i < n - 1){
printf("%05d\n", node[i + 1].address);
}
else{
printf("-1\n");
}
}
}
}
}
return 0;
}