打死不穿秋裤

 

第七次作业

输出正三角

#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,y;
       for(i=1;i<=4;i++)
       {
              for(j=1;j<=i-1;j++)
              {
                     printf(" ");
              }
              for(y=1;y<=9-2*i;y++)
              {
                     printf("*");
               } 
               printf("\n");
        } 
}

练习册 P64  8

#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);
    }

}

 

练习册 P64  9

#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");
    }


}

 

输入一个数判断是不是质数(质数是只能被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 on 2021-11-09 10:57  打死不穿秋裤  阅读(22)  评论(0)    收藏  举报

导航