编程题:
--------------------------------------------------------------
1. 共有数字1.2.3
2. 能组成多少个不重复的2位数?
3.一共有多少个不重复的2位数?
------------------------------------------------------------ 作者: ahac_wuleicity 时间: 2012-8-12 21:19
[mw_shl_code=c,true]#include <stdio.h>
int main()
{
int i, j, k=0;
for (i=1; i<=3; i++)
for (j=1; j<=3; j++)
{
printf("%d ", i*10+j);
k++;
}
printf("\n");
printf("共有%d个不重复的2位数 ", k);
sleep(5000);
return 0;
}
[/mw_shl_code]作者: lzl 时间: 2012-8-13 00:02
#include<stdio.h>
#include <stdlib.h>
int main()
{
int a = 1, b = 2, c = 3, i, x ,y,box=0,sum=0;
printf("%d%d ",a,a);
printf("%d%d ",a,b);
printf("%d%d ",a,c);
printf("%d%d ",b,a);
printf("%d%d ",b,b);
printf("%d%d ",b,c);
printf("%d%d ",c,a);
printf("%d%d ",c,b);
printf("%d%d \n",c,c);
box=3*3; // 十位数有三个选择,个位数有三个选择
printf("能组成%d个不重复的2位数\n",box);
for(i=10;i<=99;i++)
{
printf("%d ",i);
sum++;
}
printf("\n");
printf("共有%d个不重复的2位数\n",sum);
system("pause");
return 0;
}作者: zhzy0077 时间: 2012-8-13 20:24 本帖最后由 zhzy0077 于 2012-8-13 20:30 编辑
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int x, y, count;
count = 0;
for (x = 1; x <= 3; x ++)
{
for (y = 1; y <= 3; y ++)
{
printf("%d%d\n", x, y);
count++;
}
}
printf("The Count is %d\n", count);
system("pause");
return 0;
}