赞
踩
输入:123456 输出:12345654321
#include<iostream> #include<bits/stdc++.h> void recursive(char *s, int i); int main(){ char s[256]; gets(s); recursive(s,0); return 0; } void recursive(char *s, int i){ if(s[i]=='\0') return; if(s[i+1]=='\0'){ putchar(s[i]); return; } putchar(s[i]); recursive(s, i + 1); putchar(s[i]); }
#include<stdio.h>
int main(){
int a[10];
for (int i = 0; i < 10;i++)
scanf("%d", &a[i]);
for (int i = 0; i < 10; i++){
if(a[i]%2==0){
printf("%3d", a[i]);
}
}
return 0;
}
#include<iostream> #include<bits/stdc++.h> void total(int a[],int n,int result[]){ int m; //将结果数组归零 for (int i = 0; i < 10; i++) { result[i] = 0; } //统计1-9出现的数字次数 for (int i = 0; i < n;i++){ m = a[i]; while (m) { result[m % 10]++; m /= 10; } } } int main() { int a[64];//存储输入数字的数组 int result[10];//计数数组 int t;//临时输入的数字 int n = 0; while (1) { scanf("%d",&t); if(t==0){ break; } a[n++] = t; }//n代表输入数字的个数 total(a, n, result); //扫尾,输出结果 for (int i = 0; i < 10;i++){ if(result[i]!=0) printf("%d:%d\n", i, result[i]); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。