第七次作业

1,

输出正三角

#include<stdio.h>

main(){

 

       int i,j;

       for(i=1;i<=6;i++){

              for(j=1;j<=i;j++){

                     printf("*");

              }

              printf("\n");

       }

输出倒三角

#include<stdio.h>

main(){

      int i,j;

      for(i=1;i<=5;i++){

            for(j=1;j<=6-i;j++){

                  printf("*");

            }

            printf("\n");

      }

}

 

 

 

 

 

2.

#include<stdio.h>

main()

       {

       int x,y;

       for(x=0;x<=35;x++)

{

y=35-x;

if(2*x+4*y==94)

printf("鸡:%d只兔子:%d只\n",x,y);

 

 

 

3.#include<stdio.h>

main(){

       int i,j;

       for(i=1;i<=9;i++){

              for(j=1;j<=i;j++){

                     printf("%d*%d=%d\t",i,j,i*j);

              }

              printf("\n");

       }

 

 

}

 

 

 

4输入一个数判断是不是质数(质数是只能被1和自身整除的数)

#include<stdio.h>

main(){

 int a,b,c;

 scanf("%d",&a);

 for(c=2;c<a;c++){

  if(a%c==0)

   break;

 }

 if(c>=a)

  printf("%d质数",a);

 else

  printf("%d合数",a);

}

posted @ 2021-12-03 22:14  包洪帅  阅读(17)  评论(0编辑  收藏  举报