#include int main(){ int m,k = 2;scanf("%d",&m);while ( k <= m && (m%k))k++;if (m == k )printf("%d是素数!\n",m);elseprintf("%d不是素数!\n",m);return 0;}程序输入:7程序输出结果:
#includeint main(){int i,j;for(i=1;i<=3;i++){for(j=1;j<=3-i;j++){printf(" ");}for(j=1;j<=2*i-1;j++){printf("*");}printf("\n");}return 0;}程序输出结果:
#include int main(){int a[2][3]={{1,2,3},{4,5,6}};int b[3][2],i,j;for(i=0;i<=1;i++){for(j=0;j<=2;j++){b[j][i]=a[i][j];}}for(i=0;i<=2;i++){for(j=0;j<=1;j++){printf("%d",b[i][j]);}printf("\n");}return 0;}程序输出结果:
#include int main(){int i,j;for(i=1;i<=4;i++){for(j=1;j<=(2*i-1);j++){printf("*");}printf("\n");}return 0;}程序输出结果: