0 like 0 dislike
5.7k 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 | 5.7k views
1 3
Called for Help

82 Answers

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;
***** ***** ***** **** ** *** *

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

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

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

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

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

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

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

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

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



int main(){
* ** * * *** ** * ph[100];
** ** * * ** * *** * findPH[1];
**** *** **** * ** ** i;
* * * *** * *** *** * *** * * ** ***
** * ** * * ** ***** len = strlen(ph);
** * * ** * * ****** * * ** < 2){
*** * ** * *** * * * ***** * * main();   
*** * ** **** *** * *
******* * ****** ** ** * *
* * ****** **** * * * * ***
* * * ** * * *** ** ** ** * * * * ***
* * * * * ****** * * *** * ** * **** ** ** **** * == findPH[0] && ph[i+1] == findPH[0] && ph[i+2] == findPH[0] && ph[i+3] != findPH[0]){
* * * * * *** * *** * *** *** * * *** * * * ** * *** * * * * * ** ***** ***
* ****** * * ** *** **** *** * ** ** * ****** ** ** * * * ** *** 0;
* * ** * * **** * * * ** * *** * * *** *
* ** *** * * ** ** * ** * * ** *
* * *** *** * ** * **** * *** * ** found");
* ***** ******** ****

}
answered by (-134 points)
0 like 0 dislike
Hidden content!
***** * * *******
* * ** ** ***
** * **** *** ***** ** **



int main(){
** ** * *** * * ** * * * ph[100];
***** ***** * ** ****** * findPH[1];
*** * ******** * ** i;
* ** ** * **** * * * * * * * * *** * *
** * ** * **** ** * ** len = *** ***
**** ** * *** * ****** ** < 2){
** * ** ****** * * ******* **** * *** **** *  

    }
***  

**** * * ** ** * * ** * ** * ** ** *
* ** * * *** *** *** * * *
*** ** * * * ** ** ***** ** * * if(ph[i] == findPH[0] * * * ph[i+1] == findPH[0] ** ** * ** ph[i+2] == *
* * * ** * * * * **** *     *** ** * ** * *
*** ***** * *** ** * *** **** * ** * ** ** * ** return 0;
* ** ** *     }
* **** ** * ** **
* ***   * * * *** ******** *
*** * *** *** ** * ****

}
answered by (-134 points)
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 (-218 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>

#include<string.h>

void main ()

{

    int l,i,s[60]={0};

    char a[110],e,w;

    do

    {

    gets(a);

    l=strlen(a);

    }while(l<3);

    scanf("%c",&w);

    for(i=0;i<l;i++)

    {
* ** * *** * * * * * ** **** *** **** *** *** * **** * * * * * * ** * *
*** * * * ** ***** * ** ** * **** *** * ****** ** * * * *****
* * * * *** * ** * * *** *** * * * * * *** ** **** ** * ******* *** *
* * * *** * *** * * ** ***** * ** * ** * * **** * ** * ** **
** **** *** *** ** **** * * *** * ** **** ***** *** * *** * * if(a[i]<=90&&a[i]>=65)
*** * * * * * ** ** ** ** *** ****** ** * ******* ** * **
* * ** ****** * ** ** ** * *** *** *** * * ****** ** ** * * ****
* * * * * ** * **** * ** ***** ** * * * * ** ** * **** **



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

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

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

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

    }

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

#include <stdlib.h>

#include<string.h>



int main(void)

{

    

    char in[100],c;
** * ** ***** * * * * ** ******** * * **** ** i,l;
* * ** ** ** * * * ******* * * **** ** * *** ******* * * * *
* **** ** ***** * ****** *** ** ** * * **
*** *** * ** ** ** * *** ** *** * * ** * * ** * * ***

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




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


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

    return EXIT_SUCCESS;

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

#include<string.h>



int main()

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

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



int main()

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

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



int main()

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

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



int main()

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

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

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
| 4.2k views
0 like 0 dislike
52 answers
[Exercise] Coding (C) - asked Feb 23, 2017 in C
ID: 22017 - Available when: Unlimited - Due to: Unlimited
| 4.1k views
0 like 0 dislike
50 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22973 - Available when: Unlimited - Due to: Unlimited
| 4.1k views
0 like 0 dislike
90 answers
[Exercise] Coding (C) - asked Mar 16, 2017 in C
ID: 22972 - Available when: Unlimited - Due to: Unlimited
| 7.3k views
12,783 questions
183,442 answers
172,219 comments
4,824 users