作业5

#include<stdio.h>  
int sushu(int n)   
{
    int j = 0;
    for (j = 2; j < n; j++)
    {
        if (n%j == 0)
        {
            return 0;
        }
    }
    if (n >= j)
    {
        return 1;
    }
}
int main()
{
    int i = 0,t;
    printf("请输入数字:");
    scanf("%d", &i);
    t = sushu(i);
    if (t == 1)
    {
        printf("%d   是素数\n", i);
    }
    else
    {
        printf("%d   不是素数\n", i);
    }
    return 0;
}

#include <stdio.h>
int main()
{int  a, b, c, d, max;
 scanf("%d%d%d%d", &a,&b,&c,&d);
 if(a >= b){
   if(a >= c)
      if(a >= d)
        max = a;
      else
        max = d;
   else
      if(c >= d)
         max = c;
      else
         max = d;      
 }
 else{
   if(b >= c)
      if(b >= d)
        max = b;
      else
        max = d;
   else
      if(c >= d)
         max = c;
      else
         max = d;
}
printf("%d\n", max);
getch();
return 0;
}

posted on 2019-06-10 15:02  赵宇迪  阅读(112)  评论(0编辑  收藏  举报

导航