C语言问题!急!!
发布网友
发布时间:2022-04-23 12:28
我来回答
共4个回答
热心网友
时间:2023-11-02 20:02
还原需要16次,不是20次,源码和输出结果如下:
/****************************
模拟洗牌-完美洗牌法
****************************/
void main()
{
int i,j;
int a[52],b[52];
char poker[52][4]={
" AH"," 2H"," 3H"," 4H"," 5H"," 6H"," 7H"," 8H"," 9H","10H"," JH"," QH"," KH",
" AC"," 2C"," 3C"," 4C"," 5C"," 6C"," 7C"," 8C"," 9C","10C"," JC"," QC"," KC",
" AD"," 2D"," 3D"," 4D"," 5D"," 6D"," 7D"," 8D"," 9D","10D"," JD"," QD"," KD",
" AS"," 2S"," 3S"," 4S"," 5S"," 6S"," 7S"," 8S"," 9S","10S"," JS"," QS"," KS"};
for(i=0;i<52;i++) a[i]=i;
for(j=0;j<52;j++)
{
printf("%s ",poker[a[j]]);
if(j%13==12) printf("\n");
}
printf("----\n");
for(i=0;i<16;i++)
{
for(j=0;j<26;j++)
{
b[2*j] = a[j];
}
for(j=26;j<52;j++)
{
b[2*(j-26)+1] = a[j];
}
for(j=0;j<52;j++)
{
printf("%s ",poker[b[j]]);
if(j%13==12) printf("\n");
}
printf("----\n");
for(j=0;j<52;j++) a[j]=b[j];
}
getch();
}
输出结果:
AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH
AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC
AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD
AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS
----
AH AD 2H 2D 3H 3D 4H 4D 5H 5D 6H 6D 7H
7D 8H 8D 9H 9D 10H 10D JH JD QH QD KH KD
AC AS 2C 2S 3C 3S 4C 4S 5C 5S 6C 6S 7C
7S 8C 8S 9C 9S 10C 10S JC JS QC QS KC KS
----
AH AC AD AS 2H 2C 2D 2S 3H 3C 3D 3S 4H
4C 4D 4S 5H 5C 5D 5S 6H 6C 6D 6S 7H 7C
7D 7S 8H 8C 8D 8S 9H 9C 9D 9S 10H 10C 10D
10S JH JC JD JS QH QC QD QS KH KC KD KS
----
AH 7D AC 7S AD 8H AS 8C 2H 8D 2C 8S 2D
9H 2S 9C 3H 9D 3C 9S 3D 10H 3S 10C 4H 10D
4C 10S 4D JH 4S JC 5H JD 5C JS 5D QH 5S
QC 6H QD 6C QS 6D KH 6S KC 7H KD 7C KS
----
AH 4C 7D 10S AC 4D 7S JH AD 4S 8H JC AS
5H 8C JD 2H 5C 8D JS 2C 5D 8S QH 2D 5S
9H QC 2S 6H 9C QD 3H 6C 9D QS 3C 6D 9S
KH 3D 6S 10H KC 3S 7H 10C KD 4H 7C 10D KS
----
AH 9H 4C QC 7D 2S 10S 6H AC 9C 4D QD 7S
3H JH 6C AD 9D 4S QS 8H 3C JC 6D AS 9S
5H KH 8C 3D JD 6S 2H 10H 5C KC 8D 3S JS
7H 2C 10C 5D KD 8S 4H QH 7C 2D 10D 5S KS
----
AH 5H 9H KH 4C 8C QC 3D 7D JD 2S 6S 10S
2H 6H 10H AC 5C 9C KC 4D 8D QD 3S 7S JS
3H 7H JH 2C 6C 10C AD 5D 9D KD 4S 8S QS
4H 8H QH 3C 7C JC 2D 6D 10D AS 5S 9S KS
----
AH 3H 5H 7H 9H JH KH 2C 4C 6C 8C 10C QC
AD 3D 5D 7D 9D JD KD 2S 4S 6S 8S 10S QS
2H 4H 6H 8H 10H QH AC 3C 5C 7C 9C JC KC
2D 4D 6D 8D 10D QD AS 3S 5S 7S 9S JS KS
----
AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH
AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC
AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD
AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS
----
AH AD 2H 2D 3H 3D 4H 4D 5H 5D 6H 6D 7H
7D 8H 8D 9H 9D 10H 10D JH JD QH QD KH KD
AC AS 2C 2S 3C 3S 4C 4S 5C 5S 6C 6S 7C
7S 8C 8S 9C 9S 10C 10S JC JS QC QS KC KS
----
AH AC AD AS 2H 2C 2D 2S 3H 3C 3D 3S 4H
4C 4D 4S 5H 5C 5D 5S 6H 6C 6D 6S 7H 7C
7D 7S 8H 8C 8D 8S 9H 9C 9D 9S 10H 10C 10D
10S JH JC JD JS QH QC QD QS KH KC KD KS
----
AH 7D AC 7S AD 8H AS 8C 2H 8D 2C 8S 2D
9H 2S 9C 3H 9D 3C 9S 3D 10H 3S 10C 4H 10D
4C 10S 4D JH 4S JC 5H JD 5C JS 5D QH 5S
QC 6H QD 6C QS 6D KH 6S KC 7H KD 7C KS
----
AH 4C 7D 10S AC 4D 7S JH AD 4S 8H JC AS
5H 8C JD 2H 5C 8D JS 2C 5D 8S QH 2D 5S
9H QC 2S 6H 9C QD 3H 6C 9D QS 3C 6D 9S
KH 3D 6S 10H KC 3S 7H 10C KD 4H 7C 10D KS
----
AH 9H 4C QC 7D 2S 10S 6H AC 9C 4D QD 7S
3H JH 6C AD 9D 4S QS 8H 3C JC 6D AS 9S
5H KH 8C 3D JD 6S 2H 10H 5C KC 8D 3S JS
7H 2C 10C 5D KD 8S 4H QH 7C 2D 10D 5S KS
----
AH 5H 9H KH 4C 8C QC 3D 7D JD 2S 6S 10S
2H 6H 10H AC 5C 9C KC 4D 8D QD 3S 7S JS
3H 7H JH 2C 6C 10C AD 5D 9D KD 4S 8S QS
4H 8H QH 3C 7C JC 2D 6D 10D AS 5S 9S KS
----
AH 3H 5H 7H 9H JH KH 2C 4C 6C 8C 10C QC
AD 3D 5D 7D 9D JD KD 2S 4S 6S 8S 10S QS
2H 4H 6H 8H 10H QH AC 3C 5C 7C 9C JC KC
2D 4D 6D 8D 10D QD AS 3S 5S 7S 9S JS KS
----
AH 2H 3H 4H 5H 6H 7H 8H 9H 10H JH QH KH
AC 2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC
AD 2D 3D 4D 5D 6D 7D 8D 9D 10D JD QD KD
AS 2S 3S 4S 5S 6S 7S 8S 9S 10S JS QS KS
----
热心网友
时间:2023-11-02 20:02
提示你不能将第10行调用的FindCharFirst的第二个参数从char型转换成char*型,就是说FindCharFirst这个函数的第二个参数需要的是一个char*型,你在用的时候也要传入一个char*型的指针,而你传入的是一个char型字符,故提示这个错误.
这个咋改要看想实现什么功能啊,而且提供的函数只有一个声明,根本没法知道你想做什么啊.
那在s的声明处,要声明成char *s[100];这个100是你希望的数组大小啊,然后在scanf那里改成scanf("%s", s);而且即使这样改我不知道能否达到要求,因为key那里我不知道行不行,没有具体研究过.楼主最好自己思考下怎么写,毕竟这个不是很困难,自己多想想肯定没问题的.
热心网友
时间:2023-11-02 20:02
第6行定义字符串s出错,可以这样char s[100]
热心网友
时间:2023-11-02 20:03
你题目不完整吧?
C语言的问题!
5,最后一步是,当程序以混合语言编写的程序链接时,在FORTRAN库之前指定C库。重新解决了秋天的飞行问题。
c语言的问题。。。急!!!
int c = 0;//初始化所有数之和 如果a[i]%2 == 0,c+=a[i];否则:a++,b+=a[i],c+=a[i];最后:奇数的平均值就是:b/a 偶数的平均值是:(c-b)/(n-a)
C语言高手帮忙啊!急!!!
1:第3行,类型定义后面应加上分号,注意与define不同 2:main()函数,在调用CREAT()、LENGTH()和OUT()函数时不应加上linklist、int和void,你这样写是在申明函数,并非调用。3:你创建的链表是一第一个元素为头节点的的,但你却将链表长度赋给头节点,导致原头节点值丢失,无法输出。还有很多指...
C语言 在线等,挺急的
第一题 include <stdio.h>int main (void) {int i;float f,sum;for (i=1, sum=0.0; i<11; i++) {scanf ("%f",&f);sum+=f;}sum/=10;printf ("%f\n",sum); return 0;}运行结果 第二题 include <stdio.h>#define PI 3.14159int main (void) {float r,s;printf ("...
c语言作业,急!!!
1、B:排除法做,赋值运算符最低,所以选B 3、D:else必须要和if配对使用,BC项目中括号断开了两者,A选项输出语句后没有用分号结束。4、B :x>y时才执行语句 z=x;否则不执行。5、 if(a=b+c),b+c还是0,if语句还是不成立,不执行printf(“***”);所以执行printf(“$$$”);语句,输出...
C语言作业,急急急求解答
题分析:这个问题可能是由于软件代码中存在大量的冗余、重复计算或者低效算法等因素导致的。另外,如果软件需要加载大量的数据或者进行网络连接,则也会影响其启动速度。解决方案:为了解决这个问题,我们可以从以下几个方面入手:1.优化程序代码:检查程序中是否存在冗余、重复计算或者低效算法等因素,对代码进行...
C语言结构体与链表问题【急】【急】【急】【急】【急】【急】【急...
首先回答第一个问题,程序当中存在以下这几个问题:(1) char name[ ]中的数组name没有指定大小,此处可以定义为name[20](2) p = stu也有错误,应该将结构体的首地址赋给指针p,从而使p指向该结构体。正确的写法是:p = &stu;(3) (*p).name = "Mary"也有错误,此处不能这么赋值。正确的...
c语言符号问题这里的!()是什么意思
!是单目运算符,即逻辑运算中的 非。括号内(i%a)是取余运算,然后对运算结果取非。C语言中,一般默认运算结果为0是 是逻辑假,运算结果为非0时,是逻辑真,在这里,若i%a的取余结果为0,即逻辑假,那么!(i%a)即为逻辑真,然后执行if(){}内的语句。
急!急!简单c语言编程题,求编写代码
//第一题#include<stdio.h>void fun(int n){ int i,j,k,t;for(k=0;k<n;k++)//控制总行数{ for(i=0;i<n-k-1;i++)//控制输出空格,因为空格不好看见,就用*代替 printf("%c",'*'); for(j=0;j<2*k+1;j++)//控制输出字母 { printf("%c",65+j)...
这些C语言题谁会,求帮忙啊,很急
4.爱怎么用怎么用啊。关系运算符的运算对象多是数值型含义的数据类型,当然==也可以对布尔型操作。其结果为布尔型。而逻辑运算符的操作对象是布尔型,结果也是布尔型。 同上,这题目也没什么意义,写过程序的都知道用。5.false,c语言里用0表示。 考点是运算符的优先级 6.j=10 考后缀自增的...