當前位置:首頁 » 編程軟體 » 編程cde

編程cde

發布時間: 2022-06-29 16:38:57

❶ C++編程:用一個效率較高的演算法輸出所有能滿足形如:ab * cde = adb * ce 這樣的算式。

#include<stdio.h>
#include<string.h>
voidDfs(int*arr,intcur)
{
if(cur==5)
{
intA=(arr[0]*10+arr[1])*(arr[2]*100+arr[3]*10+arr[4]);
intB=(arr[0]*100+arr[3]*10+arr[1])*(arr[2]*10+arr[4]);
if(A==B)
{
printf("%d%d*%d%d%d=%d%d%d*%d%d ",arr[0],arr[1],arr[2],arr[3],arr[4],
arr[0],arr[3],arr[1],arr[2],arr[4]);
}
return;
}
for(inti=1;i<=9;i++)
{
intok=1;
for(intj=0;j<cur;j++)
if(arr[j]==i)
{
ok=0;
break;
}
if(ok)
{
arr[cur]=i;
Dfs(arr,cur+1);
}
}
}
intmain()
{
intarr[10];
memset(arr,0,sizeof(arr));
Dfs(arr,0);
return0;
}

❷ 求重復字串c編程代碼,錯在哪裡

/*

"cde" 在 "jabcdefghi" 中的索引位置是: 3

Press any key to continue

*/

#include<stdio.h>

//返回t[]在s[]中首次出現的第一個字元的索引,沒找到時,返回-1
intFindStr(chars[],chart[]){
inti,j,flag;
for(i=0;s[i];++i){
if(s[i]==t[0]){
flag=1;
for(j=1;t[j]&&flag;++j){
if(s[i+j]!=t[j])
flag=0;
}
if(flag)returni;
}
}
return-1;
}

intmain(){
chars1[]="jabcdefghi",s2[]="cde";
intres=FindStr(s1,s2);
if(res==-1)printf("沒有發現匹配的字元串。 ");
elseprintf(""%s"在"%s"中的索引位置是:%d ",s2,s1,res);
return0;
}

❸ 已知字元集abcdef編程實現輸出cde

摘要

❹ 編程,輸入一個字元串,按規律輸出。例如輸入「ABCDE」, 輸出「EDECDEBCDEABCDE」。

不好意思,用了c++,還有一點,這個程序我還沒有調試過,因為IDE之前刪掉了,所以那個循環節里可能會有一點問題,就是加加減減的問題,相信你自己調幾下就好了

#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;

int main()
{
string word;
cout<<"Please enter a word"<<endl;
cin>>word;

for(int end=0;end<word.length();start++)
{
cout<<word[word.length()-1];
for(int start=0;start<end;end++)
cout<<word[word.length()-end+start-2];
}
cout<<word<<endl;

return 0;
}

❺ C/C++編程題:查找字元串中第一個只出現一次的字元,例如字元串為「abaccde」,則輸出b,兩種演算法實現

用哈希的方式,把字元在哈希表中統計出每一個的個數來,然後從小開始遍歷出第一個為1的
代碼如下:
#include <stdio.h>
#include <string.h>

char get_onlyone(char* str)
{
char i;
int hash[128];
memset(hash, 0, sizeof(hash));
for(i = 0; str[i]; i++) {
hash[str[i]]++;
}
for(i = 0; i < 128; i++) {
if(hash[i] == 1) break;
}
return i;
}

int main(void)
{
char str[128];
while(scanf("%s", str) != EOF) {
printf("%c\n", get_onlyone(str));
}
return 0;
}

❻ 由鍵盤輸入兩個字元串(假設第一個字元串必包含第二個字元串,如第一個字元串為 ABCDEF,第個為CDE,則CDE

則CDE?
char a[200] = {'\0'}, b[200] = {'\0'};
scanf("%s", a);
scanf("%s", b); //2個字元串輸入了...

❼ C語言程序代碼

char A = "abc";
char B = "bcd" char C = "cde";
char D;
B=C;C=D;D=B;
或者直接運用位運算。

❽ C語言編程問題

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
char a[3][100];
char temp[100];
int i,j;
for(i=0;i<3;i++)
{
printf("\n第%d個字元串:",i+1);
gets(a[i]);
}
for(j=0;j<3;j++)
for(i=0;i<3-j-1;i++)
{
if(strcmp(a[i],a[i+1])>0)
{
strcpy(temp,a[i]);
strcpy(a[i],a[i+1]);
strcpy(a[i+1],temp);
}
}
printf("\n排序後:\n");
for(i=0;i<3;i++)
puts(a[i]);
}

❾ 關於c++編程問題。。。急用啊,謝謝!!!

#include <iostream>
#include <string>
using namespace std;
class student
{
private:
int num;
char name[30];
int age;
public:
student(int nu,const char * na,int ag )
{
num=nu;
strcpy(name,na);
age=ag;
}
void display(student * *ss,int total ){
student * sp=ss[0];
int i=0;
while(i<total)
{
cout<<"("<<i+1<<") "<<sp->num<<" "<<sp->name<<" "<<sp->age<<endl;
i++;
sp=ss[i];
}
sp=NULL;
}
void paixu(student ** ss,int total){
student *sp =ss[0];
student * flag=ss[0];
student * temp=NULL;
int left=total-1;
int i=0;
int num,age;
char ctemp[30];
while(left>0)
{
flag=ss[total-left-1];
sp=ss[total-left];
i=0;
while(i<left)
{
if(strcmp(sp->name,flag->name)<0)
{
num=sp->num;
sp->num=flag->num;
flag->num=sp->num;
age=sp->age;
sp->age=flag->age;
flag->age=age;
strcpy(ctemp,sp->name);
strcpy(sp->name,flag->name);
strcpy(flag->name,ctemp);
}
i++;
sp=ss[total-left+i];
}
left--;
}
}
};
int main()
{
student * ss[4];
for(int i=0;i<4;i++)
{
ss[i]=NULL;
}
ss[0]=new student(1,"ebc",11);
ss[1]=new student(2,"cde",12);
ss[2]=new student(3,"ade",13);
ss[3]=new student(4,"dsa",11);
ss[0]->display(ss,4);
ss[0]->paixu(ss,4);
ss[0]->display(ss,4);
return 0;
}

熱點內容
cf伺服器雲南一區雲空間 發布:2024-05-02 14:18:24 瀏覽:751
如何破解excel2007密碼 發布:2024-05-02 14:18:23 瀏覽:993
ios數據上傳伺服器 發布:2024-05-02 13:39:27 瀏覽:351
Php面向對象模式 發布:2024-05-02 13:33:32 瀏覽:80
安卓手機軟體如何快速打開 發布:2024-05-02 13:25:16 瀏覽:963
安卓網頁圖片不顯示怎麼辦 發布:2024-05-02 13:16:00 瀏覽:673
虛擬機搭建linux 發布:2024-05-02 13:02:48 瀏覽:186
哈弗f7配置怎麼使用 發布:2024-05-02 12:53:14 瀏覽:575
psv重新構建資料庫 發布:2024-05-02 12:43:53 瀏覽:792
農行對公密碼器的憑證號碼在哪裡 發布:2024-05-02 12:38:55 瀏覽:890