0 like 0 dislike
1.3k 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

 

[Exam] asked in Midterm
ID: 23786 - Available when: Unlimited - Due to: Unlimited

reshown by | 1.3k views

65 Answers

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

#include <string.h>

#define KK 100



int main(void)

{

    char word[KK],mod='0';

    int i,j,times=0,z=0,qq=1;


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

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

    }


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


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



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

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

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

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

    }







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

#include <string.h>

#define KK 100



int main(void)

{

    char word[KK],mod='0';

    int i,j,times=0,z=0,qq=1;


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

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

    }


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


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


***** * ***** *** ********* i<z; i++)

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



    }


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

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

    }



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

#include <string.h>



char word[100], out;

int i, C=0;



void scan(void);



int main(void){
* * ** ** * * * * ***
**** * * * * ** * * ** *** * *** *** ** *** * * &out);
* * * ** * ** * ** ** i<strlen(word)-1; i++)
** ** * * * **** **** ** **** ** * ** * ******* *** C++;
**** * * *** * ** * printf("Not found");
* **** ** * *** *** * ** **** *
* *** * * ** *** * ** * *** * * *** *** * * i<strlen(word)-1; i++)
* ** **** ***** *** * * * * * **** * * * *** * ** ** ** ** ***
*** ** ** ** * ** * *** **** *** ***** *** * ** * * *** * ** * * **** * * ** ** *** * i);
** * ** * * *** ***** * * * ***** ****** * ** ** ** ****** * * *** *** * * *
* **** * ** ** ** * * * *** ******* ** ** * * * ******* ** *

}



void scan(void){
** ***** ***** ** ** ** i<100; i++){
***** * * * * * * ** *** ** **** * * * * * *** **
* ** * * * * * *** * **** ** * **** ** * * ***
* * ** *** * * ** ** * ** * * *** * * ******* * * ** ** break;
* * ** * ** *** * *** * *** ** ** *** ** * **** * * *** * i=-1;
* * * * * * * **** ** * * * *** ** * ** **

    }

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

#include <string.h>



char word[100], out;

int i, C=0;



void scan(void);



int main(void){
*** * * * *** **** * **
* * * **** * * * ** * * * * * * * ** * &out);
* * *** ** **** *** * i<strlen(word)-1; i++)
** * * * ** ** * ** *** *** * * ** * * C++;
* ** * ***** * * ** * **** * printf("Not found");
* ** * *** ** * * *
* * ******* *** *** * * *** ** ** ** * i<strlen(word)-1; i++)
** * *** * **** ******* * * * * * *** ** * * * ** *** * * **** * * *
** * **** *** * ****** **** * * *** *** * ** **** * * **** * * * * * * * *** * ***** * ** **** i);
** *** * * * * ***** **** *** * *** *** * * * *** *** * * * ** **** ****** ** ** ** *****
*** * *** * * *** * * * ** ** *** *** ** ** * ** ** * * ** ***

}



void scan(void){
*** * * ***** ** * *** ** * i<100; i++){
** ** ** * * * *** * *** ** ** ** * *** * * ** * *
** ** * * * *** * ** * ****** *** * * ** **** ** * ****
* * * * * *** * * * ** * **** ** * ** * *** ** * ** * ** * * break;
*** * *** *** ** * * ** ** *** **** *** ** ** ** ** ** * *** * * i=-1;
*** * * * * ** * * *** * * ** *** ***

    }

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

#include <string.h>

#define KK 100



int main(void)

{

    char word[KK],mod='0';

    int i,j,times=0,z=0,qq=1;


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

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

    }


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


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


* ** * * * * * * * * * * i<z; i++)

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



    }


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

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

    }



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

#include <string.h>



char word[100], out;

int i, C=0;



void scan(void);



int main(void){
******* * * *** * * * * **
*** ** * ****** * * * * * &out);
** **** *** ***** * * **** i<strlen(word)-1; i++)
**** * * ** * * *** * * * * * *** * * C++;
*** * ** ** * ** * * * printf("Not found");
* * ** **** * **
***** ** * ** ** * *** ** * **** * ** * * * * i<strlen(word)-1; i++)
*** * *** *** * * * * * * ** * * ** * * * *** * ** **** * *** ** *
* ** * ** * ** ** * ** * * * ** * * * * * ** * * ** *** *** ** ** ** * ** **** ** * *** i);
* *** * * * *** **** ** * ** ** * ** * * *** **** * ** ** * *** *** * **** *****
** *** *** * * ******* ** * ** * * *** * **** * **** **** *

}



void scan(void){
* ** ** **** ** * *** **** i<100; i++){
* * ** ** *** *** ** * ** * * * *** ** ****
*** ** *** *** ** *** * ** * * * ************* **
** *** ** *** ** **** * * * * * * *** * * * * * ** ** * * * break;
* * * *** * ** ******* * **** * **** * *** ***** **** ** **** * i=-1;
* ** ** *** ***** ** * ** ****** * ****

    }

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



int main(){
** * *

** * ** *** char * * * *
* * ** * * char * ** ** *
* * **** *** int k;
*** ** * int temp = 0;
* * * *** char c[1];
** ** here:
* * * **** * * * *** ** * * *** *
* * * **** *** ** * ** * * int len = **** *
* * ** ** * ** * if(len *** **
* **       ** *** ** goto here;
** **** * ***   ** * * }
* ** * ** ** * * *** ******* * **** * *
* ** **** * ** * * * * int i;
* * * * *** * *** * * * * * ** * **
* * ** ** * * * ** * * * **** * * *** == c[0] ** *** ** ** * == c[0] ** * ** ** ** == c[0]){
* * ** ** *** ** * * ** ** * **** ** ** ** ** ***
** *** ** * * * * * * * *** ** * * * * **** * return 0;
** *** * * ** **** **** }
* * ** * *** }
* ** * **** * * * ** * **

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

#include <string.h>



char word[100], out;

int i, C=0;



void scan(void);



int main(void){
**** * ** *** * *** *** * *
** * ** * ******* * * **** ** **** * * *** &out);
* ***** *** ***** ** * * *** i<strlen(word)-1; i++)
* *** * ** ***** ** * ** *** * * *** * ** ** * ** * C++;
* * ** * * ** * printf("Not found");
*** *** *** * * * * **
** * ** ** *** ** ** * * * ** ** * **** i<strlen(word)-1; i++)
** * * * ** **** ***** ** * * * *** * * * ** * * ******** **** ****** **
* * * * ** * *** ** * * *** ***** * * ** * ** ** * * ** ** *** ** * * * * *** * ** *** i);
*** ** * ******* *** * * *** ****** * ** **** * * ** * * * * *** *** * ** * **
* ** ** ** * ** * *** *** * * ** * ** *** ** ** * * * * ** **

}



void scan(void){
* * * * * ** *** i<100; i++){
* * **** ** ** * ** *** * * * * * ** *** * * *** * * * * *
** **** * * * * * *** ****** *** ***** * **** ** **
* * ** * * **** * *** ** * * **** * **** ** * * ** * * * * break;
** ** ** * ** * ** * * *** ** * * * **** ** ** **** ** **** *** i=0;
* ** * * * ** ** ********** * * * **** * * * *

    }

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

#include <stdlib.h>

#include <string.h>



int main()

{
** * **** ** * **** A[101] = {0}, test;
** * * ** **** *** * *** count = 0, i = 0, j, len;


* *** * * * * ** *

    {
**** ** * * * ** ** ** ***** ** ** * ** ** ******* * **** *** A);
*** * * * ******* * * ** ******* = strlen(A);

    }
**** * *** * * * ** ** ******* < 3);
* * ***** ***** ** ** * ** *** &test);


** **** ** * *** ** = 0; i < len; i++)

    {
* ** **** **** * ** * **** ** ** * ** * ** == test)
** * * ** * * ***** ***** * ** * **
** * * ** * * **** ** ** * * ** ** * * *** * * ** * ** ** ***
* *** * ******* ********** * ****** **** * * *** *** * * ** ** * ** (count == 1)
** * * ** ** * *** * * *** * ** * ** **** * * *** * * ** * = i;
** * ** *** ***** * ** ** * ** * *** * ** * *
**** ** ** *** * *** ** * *** * ** ** ** * * == 3)
*** ** * * **** ** ** * * * * *** ** ** ** * * * * *** *
** * ** * *** **** * ** *** * * ***** * * ** * ** ** ** ** **** * ****** * *** ** j);
* ** ****** ** *** * ** * * * * ** * * * *** * * *** *
** * *** * ******* * * * ** * ***** * * ******
** ** ** ** **** ** * ***** * * * *** *** * * * if(i == len - 1)
*** * **** * ** *** * ***** ** ***** * ** *
*** ** * ****** ** * ** * * * * * * ***** * ** ***** * * *** * * * ***** ** * found");
** ** *** ** * *** ** ** * * *

    }


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

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

#include <string.h>

#define KK 100



int main(void)

{

    char word[KK],mod='0';

    int i,j,times=0,z=0,qq=1;


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

    while(1)

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

    }



    z=strlen(word);


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



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

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

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

        }

    }

    if(qq==1)

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

    }



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

Related questions

0 like 0 dislike
11 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24270 - Available when: Unlimited - Due to: Unlimited
| 290 views
0 like 0 dislike
13 answers
[Exercise] Coding (C) - asked Apr 21, 2017 in Midterm
ID: 24268 - Available when: Unlimited - Due to: Unlimited
| 354 views
0 like 0 dislike
47 answers
[Exam] asked Apr 13, 2017 in Midterm
ID: 23784 - Available when: Unlimited - Due to: Unlimited
| 970 views
0 like 0 dislike
8 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24273 - Available when: Unlimited - Due to: Unlimited
| 248 views
0 like 0 dislike
4 answers
[Exam] asked Apr 21, 2017 in Midterm
ID: 24272 - Available when: Unlimited - Due to: Unlimited
| 194 views
12,783 questions
183,443 answers
172,219 comments
4,824 users