1.
#include <stdio.h>
int main(){
printf("*\n");
printf("***\n");
printf("*****\n");
printf("*******\n");
printf("*********\n");
printf("***********\n");
printf("*************\n");
printf("***********\n");
printf("*********\n");
printf("*******\n");
printf("*****\n");
printf("***\n");
printf("*\n");
system("pause");
}
2.水仙花数
#include <stdio.h>
int main(){
int x, y, z;
for (x = 0; x <= 9; x++){
for (y = 0; y <= 9; y++){
for (z = 0; z <= 9; z++){
if (x*x*x + y*y*y + z*z*z == 100 * x + 10 * y + z){
printf("%d%d%d\n", x, y, z);
}
}
}
}
system("pause");
}
3.求Sn
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int sn(int b){
int i,c,d;
c = b;
d = b;
for (i = 1; i <= 4; i++){
d = 10 * d;
b = b + d;
c = c + b;
}
return c;
}