#include <time.h>
int main()
{
int 悉岩镇睁粗a,b
srand(time(NULL))
a=rand()
scanf("%d",&b)
a==b?printf("true"):printf("false"枣搏)
return 0
}
//运行示例:
定义三个字符变量因为A,B,C有可能和X,Y,Z中一人比
所以利用三层循环,找出所有的情况
有因为A
对手不拍答咐能和B相同
所有在对举枯B的对手所有情况进行寻找时
进行条件判断
即A!=B
同理C
对手不能袭纯和A与B的对手相同
所以有A!=C&&B!=C
A!='X'&&C!='X'&&C!='Z'
#include
<stdio.h>
#define
N
4
int
main(void)
{
char
A,B,C
for(A='X'A<='Z'A++)
{
for(B='X'B<='Z'B++)
{
if(A!=B)
{
for(C='X'C<='Z'C++)
{
if(A!=C&&B!=C)
{
if(A!='X'&&C!='X'&&C!='Z')
{
printf("\nAvs%c,Bvs%c,Cvs%c",A,B,C)
}
}
}
}
}
}
}
// 记得多给点分哦,很难写的。// C
#include <stdio.h>
int strnmerge(char*str,int n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] 悔早= "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
printf("s1 = %s\n", s1)
printf("s2 = %s\n", s2)
printf("str = %s\n", str)
return 0
}
// C++
#include <iostream>
using namespace std
int strnmerge(char*str,int 腔汪n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] = "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
cout << "s1 = " 伍前仔<< s1 << endl
cout << "s2 = " << s2 << endl
cout << "str = " << str << endl
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)