gpt4 book ai didi

c++ - ideone.com 上的 SIGXFSZ?

转载 作者:行者123 更新时间:2023-11-28 01:04:23 25 4
gpt4 key购买 nike

<分区>

我想按升序打印字符串中重复的字符。此代码编译但给出了 SIGXFSZ 运行时错误,在线 c++ 编译器没有输出...有什么建议吗?

#include <iostream>
#include <string.h>
#include <ctype.h>

using namespace std;

int main()
{
unsigned int i;
char str[26];
int a[26];
for(i=0;i<26;i++)
a[i]=0;
A:
i=0;
cout<<"Enter the string:";
cin>>str[i];

while(str[i]!=13)
{
if(isalpha(str[i]))
i++;
else{
cout<<"Invalid string";
goto A;
}
}

cout<<"You Enterd:"<<str;

for(i=0;i<strlen(str);i++)
++a[str[i]-97];

cout<<"\nLetters Frequency:";

for(i=0;i<26;i++)
cout<<a[i]<<" ";

cout<<"\nDuplicates in sorted order:";

for(i=0;i<26;i++)
{
if(a[i]>1)
cout<<char(i+97);
}

return 0;
}

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