#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
// 第一题
int li(int n) {
return n*n*n;
}
void problem1() {
for(int i = 1; i <= 9; ++i) {//百位数
int num = i*100;
for(int j = 0; j <= 9; ++j)
for(int k = 0; k <= 9; ++k)
if(num+(j*10)+k == li(i)+li(j)+li(k))
printf("%d
", num+(j*10)+k);
}
}
//第二题
bool isPrime(int n) { // 是素数返回1
for(int i = 2; i <= n/2; ++i)
if( !(n%i) ) return 0;
return 1;
}
void problem2() {
for(int i = 2; i <= 200; ++i)
if(isPrime(i))
printf("%d ",i);
printf("
");
}
// 第三题
void problem3() {
char a[] = "CddBb456!*e2";
int DaX = 0; // 大写字母
int XiX = 0; // 小写字母
int ShZ = 0; // 数字
int QiT = 0; //其他字符;
for(int i = 0; i < strlen(a); ++i)
if('A' <= a[i] && a[i] <= 'Z') DaX++;
else if('a' <= a[i] && a[i] <= 'z') XiX++;
else if('0' <= a[i] && a[i] <= '9') ShZ++;
else QiT++;
printf("大写:%d, 小写:%d 数字:%d 其他:%d
",DaX,XiX,ShZ,QiT);
}
// 第四题
struct Table {
int val;
Table *nxt;
};
Table *Head;
int length;
void create() {
Table *p = Head;
int val;
while(scanf("%d", &val) != EOF) {
p->val = val;
p = p->nxt;
++length;
}
}
void Sort() {
for(Table* i = Head; i != NULL; i = i->nxt)
for(Table* j = i; j->nxt != NULL; j = j->nxt)
if(j->val > j->nxt->val) {
swap(j->val, j->nxt->val);
swap(j->nxt, j->nxt->nxt);
}
for(Table* i = Head; i != NULL; i = i->nxt)
printf("%d ", i->val);
for(Table* i = Head; i != NULL; i = i->nxt)
for(Table* j = i; j->nxt != NULL; j = j->nxt)
if(j->val < j->nxt->val) {
swap(j->val, j->nxt->val);
swap(j->nxt, j->nxt->nxt);
}
for(Table* i = Head; i != NULL; i = i->nxt)
printf("%d ", i->val);
}
void problem4() {
create();
Sort();
}
int main() {
problem1();
problem2();
problem3();
problem4();
return 0;
}