分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include #include using namespace std;int main(void){ int a[3], i; for(i = 0; i < 3; ++i) scanf("%d", &a[i]); sort(a, a + 3); //排序后,直接用两个最小数的和与第三个数进行比较就可以了 if(a[0] + a[1] > a[2]) printf("It is a triangle\n"); else printf("It is not a triangle\n"); return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include int main(void){ int i, m, d, sum; int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; scanf("%d %d", &m, &d); for(i = 1, sum = 0; i < m; ++i) sum += month[i]; sum = sum + d - 1; //计算输入的某一天距离1月1日的间隔天数 if(sum % 5 < 3) printf("打渔\n"); else printf("晒网\n"); return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include bool IsUgly(int number){ while(number % 7 == 0) //输入的整数分别与2、3、5、7进行循环除法运算(在取模运算为0的情况下) number /= 7; while(number % 5 == 0) number /= 5; while(number % 3 == 0) number /= 3; while(number % 2 == 0) number /= 2; return (number == 1) ? true : false;}int main(void){ int n; scanf("%d", &n); if(IsUgly(n)) printf("Yes\n"); else printf("No\n"); return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include int main(void){ int num, i, j; char str[100]; i = 0; scanf("%d" , &num); while(num != 0) { j = num % 16; if(j < 10) str[i++] = j + '0'; else str[i++] = j - 10 + 'A'; num /= 16; } if(i == 0) printf("0\n"); else { for(j = i - 1; j >= 0; --j) printf("%c", str[j]); printf("\n"); } return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include #define WORM_LENGTH 20int main(void){ short h[WORM_LENGTH], v[WORM_LENGTH]; // 用于记录虫子每一节的位置,(v[0], h[0])是头部 short newHead_v, newHead_h; // 移动一步后头部的新位置 int i, j, steps; int ranIntoItself, ranOffBoard; char moves[1000]; scanf("%d", &steps); // 读入每个测试用例要移动的步数 while (steps != 0) { scanf("%s", moves); // 读入移动方向字符串 // 虫子的初始位置 for (i = 0; i < WORM_LENGTH; ++i) { h[i] = 30 - i; v[i] = 25; } ranIntoItself = ranOffBoard = 0; for (i = 0; i < steps; ++i) { // 计算移动一步后头部的位置 newHead_h = h[0]; newHead_v = v[0]; switch (moves[i]) { case 'E': newHead_h++; break; case 'S': newHead_v++; break; case 'W': newHead_h--; break; case 'N': newHead_v--; break; } // 判断是否碰到自己的身体 for (j = 1; j < WORM_LENGTH - 1; ++j) // 由于移动后尾部位置已前移一格,所以是WORM_LENGTH - 1 { if (newHead_h == h[j] && newHead_v == v[j]) { ranIntoItself = 1; break; } } // 判断是否碰到边缘 if (newHead_h == 0 || newHead_h == 49 || newHead_v == 0 || newHead_v == 49) ranOffBoard = 1; if (ranIntoItself || ranOffBoard) break; // 移动虫子除头部后的几节 for (j = WORM_LENGTH - 1; j > 0; --j) { h[j] = h[j - 1]; v[j] = v[j - 1]; } h[0] = newHead_h; v[0] = newHead_v; } // 输出移动后的状态 if (ranIntoItself) printf("The worm ran into itself on move %d\n", i + 1); else if (ranOffBoard) printf("The worm ran off the board on move %d\n", i + 1); else printf("The worm successfully made all %d moves\n", steps); // 继续读下一字符串 scanf("%d", &steps); } return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include int main(void){ int n, HH, MM, SS; int hh, mm, ss; scanf("%d", &n); while (n--) { scanf("%d:%d:%d", &HH, &MM, &SS); scanf("%d:%d:%d", &hh, &mm, &ss); if(hh > 12) hh %= 12; if(SS < ss) { --MM; SS += 60; } SS -= ss; if(MM < mm) { --HH; MM += 60; } MM -= mm; if(HH < hh) HH += 12; HH -= hh; printf("%02d:%02d:%02d\n", HH, MM, SS); } return 0;}
转载请标明出处,原文地址:http://blog.csdn.net/hackbuteer1/article/details/6678851#include #include int cmp(const void *a, const void *b){ return *(int *)b - *(int *)a;}int main(void){ int i, j, n, a[100]; while (scanf("%d", &n) != EOF && n) { for(i = 0; i < n - 1; ++i) scanf("%d", &a[i]); for(i = 0; i < n - 1; ++i) { qsort(a + i, (n - i - 1), sizeof(int), cmp); if(0 == a[n - 2]) { printf("Lie absolutely\n"); break; } else if(1 == a[i]) { printf("Maybe truth \n"); break; } else { for(j = 1; j < a[i]; ++j) --a[i + j]; } } } return 0;}
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow