#include <stdio.h>
main()
{
int i,j;
for (i=1;j<=5;i++)
{ for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
}
- 输出以下图形
*
**
***
****
*****

********
*****
***
*
#include <stdio.h>
main()
{
int i,j,k;
for (i=1;j<=4;i++)
{ for(j=1;j<=i;j++)
printf(" ");
for(k=1;k<=9-2*i;k++)
printf("*");
printf("\n");
}
}

2.鸡兔同笼
#include <stdio.h>
main()
{
int x,y;
for (x=10;x<=35;x++)
{ y=35-x;
if(2*x+4*y==94)
printf("鸡:%d只 兔子:%d只\n",x,y);
}
}

3.编写程序,打印”九九乘法表
#include<stdio.h>
main()
{
int x,y;
for(x=1;x<=9;x++)
{
for(y=1;y<=x;y++){
printf("%d*%d=%d\t",x,y,x*y);
}
printf("\n");
}

4.输入一个数判断是不是质数
#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);
}.

浙公网安备 33010602011771号