c语言输2到100的素数,求纠错,2到100素数

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/* * myfun.c * * Code generation for function 'myfun' * * C source code generated on: Thu Jan 24 18:12:57 2013 * */

/* Include files */#include "myfun.h"#include "myfun_emxutil.h"

/* Type Definitions */

/* Named Constants */

/* Variable Declarations */

/* Variable Definitions */

/* Function Declarations */static real_T rt_roundd(real_T u);

/* Function Definitions */static real_T rt_roundd(real_T u){ real_T y; if (fabs(u) < 4.503599627370496E+15) { if (u >= 0.5) { y = floor(u + 0.5); } else if (u > -0.5) { y = 0.0; } else { y = ceil(u - 0.5); } } else { y = u; }

return y;}

void myfun(const emxArray_real_T *x, emxArray_int16_T *y){ uint32_T uv0[2]; int32_T m; emxArray_boolean_T *b_m; real_T n; int32_T idx; uint32_T sqrtn; uint32_T b_n; emxArray_uint32_T *p; uint32_T np; uint32_T k; int32_T loop_ub; emxArray_int32_T *r0; emxArray_uint32_T *b_p; boolean_T exitg2; emxArray_int32_T *ii; boolean_T exitg1; boolean_T guard1 = FALSE; emxArray_int32_T *r1; emxArray_int32_T *b_ii; for (m = 0; m < 2; m++) { uv0[m] = (uint32_T)x->size[m]; }

emxInit_boolean_T(&b_m, 2); m = b_m->size[0] * b_m->size[1]; b_m->size[0] = 1; b_m->size[1] = (int32_T)uv0[1]; emxEnsureCapacity((emxArray__common *)b_m, m, (int32_T)sizeof(boolean_T)); if (x->size[1] == 0) { } else { n = 0.0; for (idx = 0; idx < x->size[1]; idx++) { if (x->data[idx] > n) { n = x->data[idx]; } }

sqrtn = (uint32_T)ceil(sqrt(n)); if (0U < sqrtn) { b_n = sqrtn; } else { b_n = 0U; }

emxInit_uint32_T(&p, 2); np = (b_n >> 1) + (b_n & 1U); m = p->size[0] * p->size[1]; p->size[0] = 1; p->size[1] = (int32_T)np; emxEnsureCapacity((emxArray__common *)p, m, (int32_T)sizeof(uint32_T)); if (b_n < 2U) { m = p->size[0] * p->size[1]; p->size[0] = 1; p->size[1] = 0; emxEnsureCapacity((emxArray__common *)p, m, (int32_T)sizeof(uint32_T)); } else { p->data[0] = 2U; for (idx = 2; (uint32_T)idx <= np; idx = (int32_T)((uint32_T)idx + 1U)) { p->data[(int32_T)(uint32_T)idx - 1] = ((uint32_T)idx << 1) - 1U; }

if (b_n >= 9U) { k = 3U; sqrtn = 9U; while (sqrtn <= b_n) { if (p->data[(int32_T)((k + 1U) >> 1) - 1] != 0U) { sqrtn = (sqrtn + 1U) >> 1; while ((k > 0U) && (sqrtn <= np)) { p->data[(int32_T)sqrtn - 1] = 0U; sqrtn += k; } }

k += 2U; sqrtn = k * k; }

m = 0; for (idx = 1; (uint32_T)idx <= np; idx = (int32_T)((uint32_T)idx + 1U)) { if (p->data[(int32_T)(uint32_T)idx - 1] > 0U) { m = (int32_T)((uint32_T)m + 1U); p->data[(int32_T)(uint32_T)m - 1] = p->data[(int32_T)(uint32_T)idx - 1]; } }

if (1U > (uint32_T)m) { loop_ub = 0; } else { loop_ub = (int32_T)(uint32_T)m; }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值