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

82 Answers

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

#include<string.h>



int main()

{
* * * * ** * ** * s[100];
* * * * *** * * **** * key;
* * * ** * * ** i=0, flag=0, mark[3];




** * * **** ** * ***** ** ** * s);
** ** **** * **** ** * * * * * *** **

    {
** * * ** ** * * ** * *** * ***** ** * *** ** * * * * **** *********** * s);

    }
**** * * ******* * * ** ****** * ** *** &key);


* * * * * * * *** ** *** * *******
* * * * *** * **
** ** *** **** * * * * * * * * ** **
** ** *** ** **** * ** ** *****
* * * * * ** ** ** *** ** ** * ** * ** ** ** * *********** * * * **
* **** ** * ** **** * * * * *********** * * *** * ******* * ** * *
* * ***** * *** * * * *** ** *
** ** * * * * ****
** *** ***** **** ** *** **
* ** ** * * * * * * *
** *** ** ** ***** ** *** * * ** * * * *** * mark[0]);
* **** * * ***** ***
* ** * ** * *****

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

    }
**** ** * * * ** * ** 0;

}
answered by (-368 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 (44 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 (38 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 (6 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 (237 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



/* run this program using the console pauser or add your own getch, ** * ***** * * * or input loop */



int main()

{
** *** * * ** * * ** i,find;
* ** *** *** ** * ** a[100];
* * ** *** **** * * *
* * * ** ** ***** *** ** ** *
* **** ** * * * ** ** ** **** * ***
* * ** * * ** * * ** *** (strlen(a)<3);
* *** *** ** * * * *
*** ** * ***** * *** *** * * %c",&find);
* * ** * * * * * * **
** ** *** * * ** * * ** ** ** * * * ** *
* *** * * ** * * * ** *
** ** * * ** * * * ** * **** ***** ***** ***** (a[i]==find && a[i+1]==find && a[i+2]==find)
** * * *** ** ** *** ******* * * ********** * * ***
* * ** *** * * * **** ** * **** * * * * ** * * ** * ** *** *** ***** * ** * * *
*** ** * * ** * * *** ** * * *** * * ***** *** ** ** *** * ***
* * * * * * * ** * * * * ***** * ** *****
* * * * ** * ** ** * * * * ** * **** if (i==strlen(a)-3)
** ** ** * * ***** * * * ** ****
** * * ******** ** * ** ** **** ** ** * * ** ** **** ** * *** ** * found");
* * ******* ** * * ** ** * ** * **** *** * * *** ** ** * *** *****
* * * * *** * * ***** ** * ** * * ********** **
* ** * ** ** * * *


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

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

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

#include <string.h>



/* run this program using the console pauser or add your own getch, ** ** * * **** * or input loop */



int main()

{
** ** * * * * ** * ** i;
* * * * * * * * *** * ** a[100],find;
******** **** *** *** ****
**** *** ** ** *** **
* * ** * *** ** *** ** * * ** ******* ** ** ****
** * * * *** ***** * * * (strlen(a)<3);
** **** *** ** *
** **** * ** **** * * * * ** * *** ** *** ***
** ***** ** **
**** * ***** ** *** ** * * * ***
* *** ** * ** *
** * * * * * *** * * * *** ** *** * ******* (a[i]==find && a[i+1]==find && a[i+2]==find)
** *** *** * * * **** **** * ** **** ***
** ** ** ******* * * ** * ****** ** ** *** * ** * * *** * ***** * **
*** * ** **** *** * * ** ** ** * ***
* * **** *** * * * **** ** ***** *** * if (i==strlen(a)-2)
* * ** * * ******** ** * * ***** ****
* *** * **** * ** * **** * ** * * * * ** ** * * ** * ** ** found");
* ** **** **** * ** *** * *** ***** *** **
* * * ** ** * * ****
** *** * ** * * * ** * 0;

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

#include <string.h>

int main()

{
* **** *** *** *** ****** * word[100],mod;


* **** * ** * * ** i,t=0,z;

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

    

    

    

   while(1)

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

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

   }

   

    

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

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

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

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

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

#include <string.h>

int main()

{
******* * * **** * word[100],mod;

    
* * ** ** * * *** * *** ** i,j,t=0,z;

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

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

    
* * * *** * ** *** *** (z<3)

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

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

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

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

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

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

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

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