Skip to content

Instantly share code, notes, and snippets.

View wingofthestar's full-sized avatar

wingofthestar

View GitHub Profile
@wingofthestar
wingofthestar / .md
Last active September 10, 2018 10:24
Gist的使用介绍

Gist的使用

  • Gist可以用来记录自己编写的代码片段,或自己想要记录的代码片段

  • 代码片段可以链接到自己的博客网页等实现共享

  • 也可以在Github的Gist中搜索关键字寻找代码片段

@wingofthestar
wingofthestar / 三位数反转(1)
Last active July 4, 2017 03:25
三位数反转(1)
#include<stdio.h>
int main() {
int n;
scanf("%d", &n);
printf("%d%d%d\n", n%10, n/10%10, n/100);
system("pause");
return 0;
}
@wingofthestar
wingofthestar / 三位数反转(2)
Last active July 4, 2017 03:25
三位数反转(2)
#include<stdio.h>
int main() {
int n;
int m;
scanf("%d", &n);
m = (n % 10) * 100 + (n / 10 % 10) * 10 + (n / 100);
printf("%d", m);
system("pause");
return 0;
}
@wingofthestar
wingofthestar / 鸡兔同笼
Last active July 4, 2017 03:24
鸡兔同笼问题
#include<stdio.h>
int main() {
int a, b, n, m;
scanf("%d%d", &n, &m);
a = (4 * n - m) / 2;
b = n - a;
if (m % 2 == 1 || a < 0 || b < 0) {
printf("No answer\n");
}
else {
@wingofthestar
wingofthestar / 确定int型整数的最小值和最大值
Last active July 4, 2017 03:24
写一个程序,确定int型整数的最小值和最大值为多少
#include<stdio.h>
void main() {
int i = 1;
while (i > 0) {
i++;
}
printf("Min = %d, Max = %d\n", i , i-1);
system("pause");
}
#include<stdio.h>
int main() {
freopen("D://WorkSpace//input.txt", "r", stdin);
freopen("D://WorkSpace//output.txt", "w", stdout);
int x;
int count = 0;
while (scanf("%d", &x) != -1) {
do
{
x = x / 10;
@wingofthestar
wingofthestar / 水仙花数
Last active July 4, 2017 03:23
输出1000~999中的所有水仙花数,若3位数ABC满足ABC=A^3 + B^3 + C^3,则称其为水仙花数
#include<stdio.h>
#include<math.h>
int main() {
for (int i = 100; i <= 999; i++) {
int a = i % 10;
int b = i / 10 % 10;
int c = i / 100;
if (i == (pow(a, 3) + pow(b, 3) + pow(c, 3))) {
printf("%d\n", i);
}
@wingofthestar
wingofthestar / 韩信点兵算法
Created July 4, 2017 04:51
相传韩信才智过人,从不直接清点自己军队的人数,只要让士兵先后以三人一排、五人一排、七人一排地变换队形,而他每次只掠一眼队伍的排尾就知道总人数了。输入3个非负整数a,b,c ,表示每种队形排尾的人数(a<3,b<5,c<7),输出总人数的最小值(或报告无解)。已知总人数不小于10,不超过100 。
#include<stdio.h>
int main() {
int i = 10;
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
while (i < 100) {
if ((i % 3 == a) && (i % 5 == b) && (i % 7 == c)) {
printf("%d\n", i);
return 0;
}
@wingofthestar
wingofthestar / 倒三角形输出
Created July 4, 2017 06:00
输入整数n<=20,输出一个n层的倒三角形
#include<stdio.h>
int main() {
int n;
int m;
scanf("%d", &n);
m = n;
for (int i = 0; i < n; i++) {
for (int k = 0; k < (2 * (n-m))/2; k++) {
printf(" ");
@wingofthestar
wingofthestar / 倒三角形输出
Created July 4, 2017 06:01
输入整数n<=20,输出一个n层的倒三角形
#include<stdio.h>
int main() {
int n;
int m;
scanf("%d", &n);
m = n;
for (int i = 0; i < n; i++) {
for (int k = 0; k < (2 * (n-m))/2; k++) {
printf(" ");