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

65 Answers

0 like 0 dislike
Hidden content!
#include * * * ** *

#include *** ** * *



int main(){



int i,j;

char *** ** * find;



gets(input);
* ** * ** * **
* **** * *** ***
*** *** * *** ** *** * * *** ** *
*** *** * * ***
**** * *** * ** * * ** *

}
** *** * *** * * ** * &find);


* * ** * * * ** *
** * **** * ** * ** *** **** ** ** ** * * ** * ** * *** * * * == find){
* ****** * * ** * * * **** * * ***** * ** ** *
** * * * *** * ****** *
* ** * *** ** * * *
* * ** * ** * * **
**** * * ** found");

}









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



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

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

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

#include ** *** ***** *



int main()

{
* * **** *** *** *** ch, str[100];
*** * ** *** * ** i, len;
** **** *****
* **** *** *** ** * **
**** * *** *** *** ** * * ** * ** * * * * **
** * ** ** ** * ** ** * * **** * = strlen(str);
*** * *** * * * * * * while(len < 3);
*** **** * ** ***** * * ** ** * * *** * = getchar();
** ***** * * * = 0; i <= len-3; i++)
* * ** * * *** * * * * **** ***** == ch && str[i+1] == ch && str[i+2] == ch)
* * * * * ** * * * ** *** **** * * * **** **
* * * * ** *** ** *** * * * * * ** ** * ** * * * * * * ** * ** ** * ** ** ** ** * *********
** * **** ** *** ** *** ** **** * * * * * * * * **** * * 0;
* * ** * * * ** * ** * * * * * **
*** ** * ***** ***** ** * *** *** * * found\n");
** * * **** * ** 0;

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

#include * * * **



int main()

{
** * ** * ** * ** * * ch, str[100];
**** **** ** ** *** i, len;
* *** * * * * ** * *** *
*** **** ** ***** * *****
***** * * ** ** * * * * * * *** **** * * ** *
*** **** **** *** ***** * * *** ** = strlen(str);
**** ** ** * ** while(len < 3);
* * * * ** ** ** * * * ********** * * * = getchar();
* ** ** * ** * * ** * *** ** ** = 0; i <= len-3; i++)
*** * * * * * * * * * **** * * * ** ** ** == ch && str[i+1] == ch && str[i+2] == ch)
*** ** *** ** * * * * ** *** * * * *
** *** * ** * ***** * * * * *** ** * *** ****** * * * * * *** * * * * ** * * * *** **
** **** ***** * ** * * ****** **** * * ** * *** ** * * *** * ** ***** 0;
*** * **** * * ******* * ** * * * *** * ** * *
****** * ** * * * ** * *** found\n");
* ** * **** ** *** 0;
answered by (126 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--;
* * * ** * * * * * *** **** * * *

    }

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



#include * * ** ** *







int main()



{


** * ** *** ***** i, count1 = 0, count2 = 0;


* * * * ***** * **** *** ** input[100];


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


**** * * * * (i = 0; i < strlen(input); i++)


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


* * * * ****** ** ***** *** * ** **** * * * (input[i] == 'a')


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


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


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


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


* * * *** * * **** * (i = strlen(input) - 1; i >= 0; i--)


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


* ** * *** * * **** * * * ** * ***** ** ** * * == 'a')


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


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


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


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


* ** * ** * * (i = count1; i < strlen(input) - count2; i++)


* * * ** * ******* * * ***** ** *** ** * *** **** *** * * * * input[i]);


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



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

#include <string.h>



int main()

{
** * *** * * ** * i, count1 = 0, count2 = 0;
* *** * * ** ** * * input[100];
*** * **** ****** ** *** *** * ** * ** &input);
***** * ** ** * ** ** **** (i = 0; i < strlen(input); i++)
** * * * * * *
* ** * * ****** * ****** * ** *** * * * **** (input[i] == 'a')
** * **** *** *** ******* * * * * *** * * ** ** * * * * *** * *** **** * ***
*** * * ** *** * ***** * * ** *** * * * * **** ** *
* * * * * * **** *** * ** *** ** * * *** ***** * * **** ** * * * *
* ** * * **********
** * ******** * * * * ** * (i = strlen(input) - 1; i >= 0; i--)
** * * * * * * * **
* ** * ** ** * *** * * * *** * * * == 'a')
* * * * * ********* * **** **** * ** ******** * * * ** *** * ***
** * ****** * * * * ** *** ** **** *
*** ** * * * * ** *** * * * * ** ** * *** ******** * * *** * * * *** * *
* *** * * ** * ***
** **** * * * ** * * (i = count1; i < strlen(input) - count2; i++)
*** * ** *** **** * * *** * ** ***** * **** ** *** ** input[i]);
** ** ** ** * *** * * * 0;

}
answered by (126 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--;
* ** *** ** *** * * * ** * * * * * * **

    }

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

#include<string.h>



int main()

{
*** * * ** * * ** * len,i;
** * ****** ** * ** **** A[100],B[10];
** *** ** * ** * ***** ** *** * *** *
* ** * * ** ** ** ** ** ** **
* * ** * ** ** * * * **
* *** * ***** * ** * * * i<len; i++)

    {
* ** *** ** * * * * * * ** * * * * * * ** *** && A[i+1]==B[0] && A[i+2]==B[0])
** ******** * * * * * * * ** * ***** * *
** **** * * * ** ** * ** **** *** * * * * * * * **** * ** ** ****
* **** * **** ** ** * ** **** ** * ** * * *
* * * *** ** **
* * * * * * * * * * * *
* * ***** * * * * *
** * ** * ** *** *** * *** ** ** * ** ********** * * ** * * **
* * * * ** * * *** * *
** * ** * * * ***
* ** * * * * * * * *** ** * found");
* ** * ** * ******* * * * * 0;

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

#include <string.h>



char word[100], out;

int letter[24]={0}, i, j, max;



void scan(void);

void C(void);



int main(void){

    scan();

    C();
** * ** *** ** * * * **** **** ** * * * &out);
* ** * ** *** * ** *** ** i<100; i++)
* * * * * ** *** * ** * * ** ***** * * * ***
*** * ** ******** * * * **** * * ***** * **** **** ***** **** **** * ** * * * ***** ** **** *
* * *** ** *** ** ** ** * *** * * * * *** * ** * * * * **** * * **** ** ******* * * **** * * ***** * i);
* * ** * ** ** * * * *** * * *** ** **** ****** * ** * ** * **** * * ** *
** ** * * ** * *** * ** * ***** * * * *** * * * * ************ ****
* ** * * * ** ** ** ****** ** ***** * * * * ** ** * *** * printf("Not found");
* **** * *** ** ***** * ** *** ***** *

}



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

    }

}



void C(void){
* * *** * *** * * *** *** *** i<strlen(word)-1; i++){
** *** ** * * ** * *** **** * ** ***** * j<='z'; j++){
** *** * * * * **** * ** ** * * * * ** *** ** * * ** ** *
* * * * **** * * * * ** * ** ** * ** * * ** * ** * ** * * ** ** ***** ** ** * * * * *
** * * *** ** * *** * * *** ***** * ** ** * * *** ** * *** * *** ** * ** *** * * ** *****
** ** **** * * * *** ** * * * * ** ** * ** * ******* **
** * * * * *** * ******* **** * ** * * * **** **

    }

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

Related questions

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