0 like 0 dislike
10k views

Write a program that reads a string of up to 100 characters, and if its length is less than three characters, it should force the user to enter a new one. Next, the program should read a character and check if the string contains the input character three times in a row. The program should display the position of the first triad found.

Sample input:

fg
DuplicateThis
D

Sample output: 

Not found

 

Sample input: 

Deeeply
e

Sample output:

1

Sample input: 

Deeeppply
p

Sample output:

4

 

[Exercise] Coding (C) - asked in C by (12.1k points)
ID: 22674 - Available when: Unlimited - Due to: Unlimited

edited by | 10k views
1 3
Called for Help

82 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>



int main()

{
* ******** * * * * *** * * input[100];
* ******* * * * ** * * c;
***** ** ** * * * * count = -1, i;
* * ** *** * * * (;

* ***** * *** *
*** * * * ** ***** *** **** * * *** *** * ** *** **** * ** &input);
* **** * * *** ** * * ** ******* * * ** * * (strlen(input) >= 3)
** * * **** * ** * ** ** ** * * * * * * * **** ** ** *** * *****
* * ** * ** *** * * * *
* * * **** * ****** * ** * ***** %c", &c);
* ** ***** * *** * * ** (i = 0; i < strlen(input); i++)
** ****** * ** * ** **** *
** * * * ** * *** ***** * * * ** * *** (input[i] == c && input[i+1] == c && input[i+1])
***** * * * * ** **** ***** * * ** * **
* ** ** * * ** * ****** **** * ** * ** * * * * * * *** ** * * = i;
* * * * * * **** * * * ** * ****** * * ** * ***** *** *** **
** **** * ** ** ****** ** ***
* ** ** * * ** * **
** ** * ******* * *** ** * (count < 0)
** * * ** *** ** **** * * *** * * ****** * * * ** found");
** * ** *** *** * *
**** ** ******* * *** **** * * **** **** ** ** * * *** count);
* * ** * * ** ** ** 0;

}
answered by (-48 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main()

{
** * *** *** * * ** ** a[100],check;
*** * ** **** ** *** **** len,i,stop=0;
** ***** * * * *** * *** count=0;
* ** * * **** ** * * cont=1;
* * ** ** * **** * ** * *

    {
* * * * ** ** ** * ** ** *** * * ** * * * ** *** * *
* * ***** * * * ** * * ***** * ***** * * ** *
* * ** *** *** * * * ** **** * ****** ** * ** ******* *
* ** ** * ***** *** * ** * *** * ** * * ** **** ****** * ** ***** * * *

    }
** *** * * ******** * * ***** * * * %c",&check);
****** ***** * ********** * ***

    {
** ** * ******* ** ** * ***** * *** * * * ****
** *** * *** * ** * ** *** ** ** * * ** ** ** ** ** * *   
**** *** **** * ***
* ** * *** * * * ******** ** **

    {
* *** * ** ** * * ** * * * * * * ** * * * * found");

    }
* * ****** *** * ** *** **

    {
**** * ** * * ***** ** * * * **** ** * **** * ** ***
*** ***** * ** * *** * * *** * ***** * **** *
*** * ***** * * ** * * * ** * * * * *** *** * * ** ** **** *** *
* ** *** ** * *** * *** ***** * *** ** * * ********* * * *
** *** * ** **** ******* * * * ** * ** * **** ** * ** * ** * * ** * * ** ** *
** * ** ** ********* ***** * * *** ***** ******* ** *** * ** *** ** * *
** * * *** * * *** * ****** * * **** * * ** *** * ** * *   
** *** ** * * *** * ** * ** *** ** * * *
* ** * ***** ** *** ** * * * ** * ***** * * * * * * * * ** ******
* * * * **** ** * *

    
*** ** * ** ** ** * ** 0;

}
answered by (-384 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main()

{



int a=0,b,c,d,e,f,i,j;

int n[100]={0};


** ** *
*** *** * * ** ** ** **
* *** ****** *** * * ** ** = getchar();
** *** * * ** * * *** * *
* **** *** ** * ** ** *** **** * *
******* * * * *** *****


** *** * * * = getchar();


* * * ** * **
* *** * * ** * * * * *


* *** *** ** ** ** ** f)
* *** * *** * ** * * ** *** * ** * ** ****


** ** ***** * ** ** **
***** * * * * * * *** * * * * ** * ** ** * * ** * * *
* * *** *** * ** * * * * ** * ****
*** * ** ** * * ** * *

//if(n[i]==0)
* *** *** ***  break;


* ** ** ** ** * * *** **
****** **** ** ** * * * ****  a=0;

if(i==99){

printf("Not Found\n");

break;

}


** *** * **** * *** ** *
* ** * * ** * * **** * ** ** * **



}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main()

{
* *** ** *** * ** * * ** a[100],check;
** * ** * * * ****** len,i,stop=0;
* * ** ** ********** * * * * count=0;
* * * ** * ** * *** * cont=1;
** *** **** *** * **
* ****** * ** *
** *** * * **** * * * * ** ** * * *** ** * ** * * ** *
* * * * * * * * * * * **** *** * * *** * *
** * *** ** ** ****** ** ** ** * **** *** ** * **** * ****
* * *** * *** * *** ******* * * * ** * * * ** * * * *** * *

    }
** * **** ********* * * ** * * * *** *
* * *** * **** * ** * * ** ** **** *

    {
*** * ** *** * ***** ***** *** ** *** * **
* * *** * * ** ** * ** *** * **** * * ** * * *** ** ***** **** * ***   

    }
** * * * *** ** * *** *** ** *

    {
*** *** ** *** * ***** * **** * * **** *** * ** * * *** found");

    }
**** ** *** * * *** * ** ***

    {
***** **** * ** * * * *** * **** ** * ** ***** * *** *
** ** * * * **** * ** ** * * ** * ***
** ** * *** *** **** **** *** *** *** * * * * ** ** ** ** ** * ** * *
*** * * * * * ** ** * ***** * * * ** * ** *** * * ***
** *** * ** *** *** ** * ***** * ** ** *** * * * * **** * **** * *** ****** *** * * ** *
*** * * ** ***** * * *** *** * * ** ** **** * * ** * **** * * **** **
*** * * * ** ** * ** ** * ** *** * * ** * **** * ** * *   
* ** ** ** * *** * ** * * * * **** * * **** ** * *
* * ** * ** *** ** ***** * ** * *** * ** ** * * * ** * ***

    }

    
* * ** *** * *** ** *** * * 0;

}
answered by (-384 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main()

{
** * * ** ** * * * * a[100],check;
** **** ** * *** * len,i,stop=0;
*** ** * ** * * * * count=0;
* ** * *** *** * cont=1;
* * ** * ** ** ** *** * **

    {
* *** ** * * * **** ** ********* **** * *** **** ** **** * * **
* ** * *** ** * ** ** ** **** * ******** *****
*** ***** ** ** * ** ***** * **** ***** * * *****
********* * **** *** * ****** *** * * * ** * * ******** ** *** ***

    }
* ** * ***** * ** ** * **
**** * **** ** * *** * ** * **** * * * **
*** * ** * ** ****** * * * * **** * *
** * ***** **** *
****** ***** **** * ** * * * ** * * *** * * * * * * *
* ** ** * ** ***** * * * * ** **** **** ** * * * * * *** ** *   

    }
** *** ******* ** * ** * ** *

    {
* * *** *** * * * ***** *** * ** * ** ** * * * found");

    }
** * ** * * * * ** **

    {
*** * * ** *** ** ** ** ** * *** * * ***** * * * * * * *
** * * * ** ** **** ** **** * * * ** ** ** *
** ** * ** ** * ** *** * *** ** ** *** * * * **** ** ** ** * **** * * *
*** *** * * * ***** *** * ***** * ** ** * ***** * * * **
** * * **** ** ** * * ** *** ********** * ** *** *** * * * ********** **** * *** * * * * ***** **
** * **** ** *** * * * ** *** ** **** ** * * * * * * ** ** *** * * **** * * **** * * *
****** * **** **** ** * ***** ** * *** ** ** ** * ** * ***** * * * *   
* ***** * ******* * ***** * * * ** ***
* ***** **** ** *** *** * ** ** *** **** *** *** * * *** *

    }

    
* * ** * * *** ** ** * * 0;

}
answered by (-384 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int main(void){

    int i, num;

    char input, words[100];



    for(i=0; i<100; i++){
* ** * **** ***** * * ** * * ** ** *** ** ** ** * * * *** * ** &words[i]);
* ** * * * ** **** * * **** *** *** * * * * * **** **
*** * * * ** *** ******* * * * * ***** * * * ** * * ***** ****** * ** *
* * * *** *** ** ** ***** * *** * ** * *** * * **** ** * ******** ****** ** * * * * * *
* * **** **** * *** ** * *** *** *** * * * *** *** ** * ** * **** * *** ** * ** *** * ***
**** ** * * **** *** * ******* * ** * * * * ** ** * * ** *
* *** * *** * * ******* * ** * ****** *** * ** ** * ** ***** *
* * * *** ** ** ****** * * * * * ** ** *** * * ** ** ***** ***** * * ** * * *** * **
*** * ** * * ** * * * ** **** *** * ** *

    }


* * *** * ** * * * ***** &input);


* * ** * ** * ** ** *** i=0; i<100; i++){
* ** * * ** ********** * **** **** **** * * *** * * *
* ** ****** ***** **** ***** * * ***** * ** *** *** ******* *
* ***** * * * * *** **** * ** *** * * * *** ** *** * * *
* * ** * * *** ** **** ** * * * ***** ** **** * ** ** *** * * *

    }


**** ** ******** * *** ** *
*** ** ** ** ** * ****** * ***** * *** * **** * *** found\n");

    else{
*** * * * ******* * * * * ** * *** * * **** *** * i<100; i++){
* * ** * ** ** *** * * *** * ** **** ***** * * * * * * * * ** * * * * *
* * *** * * * ******** * * ** ****** ** ***** * **** ** ******* **** ** * ** * **
* ** * ** ** * ** ** ** * ** ** * * **
**** * * ** ** *** *** *** * *** * *** * * ***** * * * ** * ***

    }



    return 0;

}
answered by (-581 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>



int getPositive(void);

void clean_input(void);



int main(void) {
*** * * * * **** * ** * * ** ** * **


** *** *** ** *** * *** *** ** * * 0;

}

int getPositive(void) {
* * * ** * ***** ** ** number;
* ** ** * ** * * buffer;  
* **** * * *** * ** *** flag;    
** * **** **** *** *** * **
* ** ** ***** *** * *** * ** * *** * * = * ** *** ** * * &number, &buffer);



**** * ** * * * * * *** **** ** ** ** ** (flag !=2 || buffer!='\n') {


* * * * **** * ** * * * ** * ***** ** ** * ** *** *** *** ********* * *
* ** **** * **** *** * ***** * * * * * * ** * * ** **** **** * *** * *** *** *** * ** * * ** have typed non numeric characters.\n"
* * * * ** ** ** * * ** ** **** * ** * ** ** * * ***** **** * *** ** ** * * * ** **** **** type an integer\n?");
** * * **** ** *** * * *** * * **** ** ****** * **** **** * **** = ** * ** * ****** &number, &buffer);
** ** * *** **** *** * ** ** * **


** * * ** **** * * * * * ***** ** * * * *** * * * {
** * *** * ** ** * *** * * * * * ** * * * ** *** * * * * * ** * ***** * ** have typed a non positive integer\n"
* ******* *** *** * * * ** ** **** * * * * * * * ****** *** * * **** ****** ** * ** * ** ** * ** * * * * **** type a positive integer\n?");


* ** *** ** * ** ** * *** * *** * *** **** else { * ** * * ** ** ******
* * * * * * * * * * ** ** * * * *** * * ** ****** **** *** * **** **
* ****** ** *** * ****** * ** * * * * *


* * ** * ** * ** *

}

void clean_input(void) {
* * ** **** *** ** ** * * * (getchar()!='\n');
** * *** ***** ** * ** *

}
answered by (38 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main()

{
* * ** * *** * * *** ** * ******* a[100],check;
* * ** * * ** ***** * len,i,stop=0;
* ****** * ** ** * ** * count=0;
* * ** **** * *** * * cont=1;
*** *** ***** * ***** ** * * *

    {
***** *** ***** * * ** ** **** * ** * * * * * ** ** * * *** *
*** * ** ** ** * *** * * * ***** ****
* * * *** ** ** * * * * ** ****** ** * * * **** *
* ** ***** * * ** * ** * * ** **** * * ** ** ***** ** * * * ***

    }
* * ****** * * ******* * * ** ** *
* ** ***** * ** ** ** * * ***** ** **

    {
**** * ** ** * * ****** * * *** ****** * *
* ****** ** ** * ***** * * *** ** **** ***** ** * ** * * ** *   

    }
**** * *** * * *** ** ** *** *

    {
* * * * * * ** ** * ***** ** ** * * * ** ** ** ** found");
** * * * * ** * ** * * * * * *** 0;
* ** * **** * *** *
** * *** * * * * * ******

    {
** *** ******* * *** * * * * * * * * *** *** * * **** * ***** * **
** * * ** ** * ** * * * * * ** * ***
* * * * * * ** **** * * *** ** * * **** ******* * ** * ** * * *
* * * ***** ** * * ** ****** * * ****** **** ** * ** ** **
** *** ** ** * ** **** * * **** * ** ** *** ** * * *** * ** ** * ** *** * *** **
* * * *** * *** * **** *** ** * * ** * *** * ***** * **** ** ** * * ** ** * *** * ***** *
* * * *** ** * **** ******* * * ** *** ** * *** ** * * *** **   
* *** *** * *** * * * *** * * **

    }
* **** * ******** * * * ** * * ** **

    
** ***** * * ** ** * 0;

}
answered by (-384 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>



int main(void)

{
***** * * *** ** * ch[100],c;
* * * * *** * *** ** k=0,i,num=0;

   do{
***** ** ******* ** * * **** * *** * * * **


*** **** * * ** * * * * * ** ** **
* ** * * ** * ** ** ** *
******* ******** *** **** * *** *** * * * * * *


** ** * ** * * * * * * * * * *
****** **** * * * *
* ** ** ** * * * ** ****** * *** * ** ****
** * ** * **** ** * ** ** * *** **
* **** *** * ***** * * ***** ** **** ** ** * * **** ** ***** *


* * **** *** * **** *** * * ** **** * ** ** **
* * ** *** * ** * * * * * * ** *
* * ** * ** * * * ****** ****** **** **
** * * * * * * ****** * ** * * * ** **** *** ** * *** *****
* *** * * * * * * * *** ** * * *

    }
*** * ****** * * * * * ** *
* * * **** ** * * ****** *
** ** *** ** ** * * * * * * *** * ** ** * *** **** found");

    }
* *** * *** * * *** *** **

    {
** * ** * ****** * * * ** * **** ** * * ** *** ** **

    }



}
answered by (-412 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>



int main(void)

{
** ****** ****** * ** ch[100],c;
* ** *** * ** * *** * ** * k=0,i,num=0;

   do{
*** * ** ** * ** ***** *** ** ** ***** * ** **** * *** *


** * ******* * * ***** * * **
* * *** ** *** **** * ** * **
* * *** * ** * ** *** ** * ***** * * **


* ** **** * * * ** * * * * * *******
****** ** * * ******
* * ** ** * ** * * **** *** ** **
** * * * * *** * ** ** **** ** *** *** ** *
* ** ** *** ** ** * ** ** ** * * ******* ******** * * * ** *


* * ** **** **** *** **** *** * * ** ** * **
** ** ** ** * * ** * *** * *** ****** * * * *******
*** * ** ** * * * * ** *** *** **** *
** **** * *** **** ** ** * * * ** ** **
***** * * * * ** * *** * * * *** * **** * * *

    }
** ******* * * *** *
* * * * * * **
** * * ** * * ** * ** * ** ** *** *** * ** ******* **** *** found");

    }
* ***** ***** ** * *

    {
*** ** * ** **** * * ** ** **** * ** * * * * **** * * ** *

    }



}
answered by (-412 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.64
©2016-2026

Related questions

0 like 0 dislike
56 answers
[Exercise] Coding (C) - asked Mar 9, 2017 in C
ID: 22673 - Available when: Unlimited - Due to: Unlimited
| 7.7k views
0 like 0 dislike
52 answers
[Exercise] Coding (C) - asked Feb 23, 2017 in C
ID: 22017 - Available when: Unlimited - Due to: Unlimited
| 7.2k views
0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22973 - Available when: Unlimited - Due to: Unlimited
| 7k views
0 like 0 dislike
90 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22972 - Available when: Unlimited - Due to: Unlimited
| 12.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users