#include<stdio.h> #include<algorithm> #include<cmath> int judge(int a) { int j; for (j = 2; j <= sqrt(a); j++) { if (a%j == 0) return 1; } return 0; } int main() { int i; for (i = 1; i < 100; i++) { if (judge(i) == 0) printf("…
动手有益. 输入一个表达式,没有括号,数字小于0-9之间,输出计算结果,所有的中间结果化为整形.例如: 输入:3+8×2/9-2 输出:2 /** * input a calculate string, calcuate the value * the number between 0-9 * round the middle vlaue to int * */ public static void main(String[] args) { //8*6+2-6/3*6+2 String c…
输入一个正数n,输出所有和为n连续正数序列.例如输入15,由于1+2+3+4+5=4+5+6=7+8=15,所以输出3个连续序列1-5.4-6和7-8. #define N 15 void findSubquence(int n) { int end = (n + 1) / 2; int small = 1; int big = 2; int sum = small + big; //N/2<=small<big,small>N/2,否则,small+big>N while (sm…