gpt4 book ai didi

c++ - dev-c++ 中的参数错误太多

转载 作者:行者123 更新时间:2023-11-28 05:54:56 26 4
gpt4 key购买 nike

这是我一直在为我的学校项目开发的程序。我遇到了一个我不太明白的错误。我正在使用 Bloodshed Dev-C++ 4.9.9.2 和错误 I我得到的是“在函数‘voidCaesar()’中,文件中此时函数‘int estelitera()’的参数过多”(引用第 55 行)。

#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<stdio.h>
using namespace std;

void afisareMeniu();
void criptCaesar();
void criptMansfield();
void decriptTranspozitie();
int esteLitera(char);

#define CRIPTCAESAR 1
#define CRIPTMANSFIELD 2
#define DECRIPTTRANSPOZITIE 3
#define IESIRE 4
int main()
{
int nrOptiune;
for(;;){
afisareMeniu();
std::cout<<endl<<"\n\n\n";
cin>>nrOptiune;
if(nrOptiune==CRIPTCAESAR)criptCaesar();
if(nrOptiune==CRIPTMANSFIELD)criptMansfield();
if(nrOptiune==DECRIPTTRANSPOZITIE)decriptTranspozitie();
if(nrOptiune==IESIRE)break;
}//for
return 0;
}//int main
void afisareMeniu()
{
system("cls");
cout<<"\n Proiect Programarea Calculatoarelor"<<endl<<"Calculatoare 1.1.1";
cout<<"\n\n 1.Criptare Caesar"<<endl;
cout<<"\n\n 2.Criptare Mansfield"<<endl;
cout<<"\n\n 3.Decriptare prin transpozitie cu 2 jumatati"<<endl;
cout<<"\n\n 4.Iesire"<<endl;
}
void criptCaesar()
{
system("cls");
cout<<"\n\n Ati ales criptare Caesar"<<endl;
char s1[100];
char s2[100];
cout<<"\n\n Introduceti textul pentru criptare"<<endl;
cin.get();
cin.get(s1,100);
strupr(s1);
int L=strlen(s1);
int i;
for(i=0;i<L;i++)
if(esteLitera(s1[i]==1)){
if(s1[i]=='X')s2[i]='A';
else if(s1[i]=='Y')s2[i]='B';
else if(s1[i]=='Z')s2[i]='C';
else s2[i]=s1[i]+3;}
else s2[i]=s1[i];
cout<<"Textul criptat este: "<<s2<<endl;
cout<<"Apasati o tasta pentru a reveni la meniu.";
getch();
}

void criptMansfield()
{
system("cls");
int i,j,k,x=0;
char rez[200],c[100];
char a[5]={'A','E','I','O','U'};
char b[5]={'A','E','I','O','U'};
char p[5][5]={'A','B','C','D','E',
'F','G','H','I','J',
'K','L','M','N','O',
'P','R','S','T','U',
'V','W','X','Y','Z' } ;

cout<<" "<<"Criptare Mansfield"<<endl<<endl;
cout<<"Introduceti textul pentru criptare:";
cin.get();
cin.get(c,100);
strupr(c);
for ( k=0;k<strlen(c);k++ )
if ((c[k]>='A')&&(c[k]<='Z'))
for ( i=0;i<=4;i++ )
for ( j=0;j<=4;j++ )
if ( c[k]==p[i][j] ){rez[x]=a[i];
x++;
rez[x]=b[j];
x++;}
else;
else{rez[x]=c[k];
x++;}

rez[x]=0;
cout<<rez;
getch();
}

void decriptTranspozitie()
{
system("cls");
char s[101],x[51],y[51];
int i,j,optiune;
cout<<"Decriptare transpozitie cu doua jumatati"<<endl<<endl;
cout<<"Dati textul pentru decriptat:";
cin.get();
cin.get(s,100);
strupr(s);
if(strlen(s)%2==0){
for(i=0;i<strlen(s);i+=2)
cout<<s[i];
for(j=1;j<strlen(s);j+=2)
cout<<s[j];
}

else if(strlen(s)%2!=0){
for(i=0;i<strlen(s);i+=2)
cout<<s[i];
for(j=1;j<strlen(s);j+=2)
cout<<s[j];
cout<<s[j]; }
cout<<"\n\n\nPentru a reveni la meniu apasati tasta 1!\n";
cin>>optiune;
switch (optiune)
{case (1) : { afisareMeniu(); break; } }
}
int esteLitera(char x)
{
if((x>='A')&&(x<='Z'))
return 1;
else return 0;
}

最佳答案

您对 esteLitera 的声明是错误的。您将函数声明为

int esteLitera();

然后您尝试使用参数调用它。将声明更改为

int esteLitera(char);

此外,您使用 bool 参数调用 esteLitera,而不是 char:

if(esteLitera(s1[i]==1)){

关于c++ - dev-c++ 中的参数错误太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34385266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com