#5
by hanoha1631 » 2年前
#include<stdio.h>
#include<stdlib.h>
int main(){
char *str;
int i,j,count=0;
str=malloc(1024000);
scanf("%s",str);
for(i=0;*(str+i)!='\0';i++){
for(j=0;*(str+j)!='\0';j++)if(*(str+i)==*(str+j))count++;
if(count>=2){
printf("重複あり\n");
goto a;
}
count=0;
}
printf("重複なし\n");
a: return 0;
}
count=0;の処理を抜かしていたためにうまく実行されていませんでした。
御二方、回答ありがとうございました!!
#include<stdio.h>
#include<stdlib.h>
int main(){
char *str;
int i,j,count=0;
str=malloc(1024000);
scanf("%s",str);
for(i=0;*(str+i)!='\0';i++){
for(j=0;*(str+j)!='\0';j++)if(*(str+i)==*(str+j))count++;
if(count>=2){
printf("重複あり\n");
goto a;
}
count=0;
}
printf("重複なし\n");
a: return 0;
}
count=0;の処理を抜かしていたためにうまく実行されていませんでした。
御二方、回答ありがとうございました!!