0 喜歡 0 不喜歡
10.9k 瀏覽

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

 

[考試] 最新提問 分類:Midterm |
ID: 23786 - 從幾時開始: 無限制 - 到幾時結束: 無限制

重新顯示 用戶: | 10.9k 瀏覽

65 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include **** ** ***

#include * * * ***** *

#include ****** * **

int main(){

 char s[101];

 int i,a,b=0,j;

 char key ;

 

while (a<3){


** * * * *** * * ** * **
** * **** **** strlen(s);

}

fflush(stdin);
* * *** * ** * ** * ** ** * * *** * *

 
* ** * ****
***** **** * * **** ** * *
* *** * ** * *** * ***** ** ***** ***** * **
* * *** *** * * * * *
* * * * **** ** ***** * (b>=3){
* * * *** **** * ** * * *****
* * * ** ** * * * * * * ***** **** * *****
* ** * ** ****** * * *** * ** ** ** * *** ** ** ** * *
* * ** ** *** * *** ** ** * * ***** * * * **** 0 ;}
***** * * * * * ** * * *
* * *** ** ** * **
* ** * ** ** * *** *

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

 
*** ** ** * 0;



}
最新回答 用戶: (-136 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** ***** * ** **

#include ** * * * *

#include * *** *** *

int main(){

 char s[100];

 int i,a,b=0,j;

 char key ;

 

while (a<3){


* * * ** ** * **** ** ***** ** *** ***
* * **** ** **** strlen(s);



}

fflush(stdin);
* * * * * * ** ** * * * ** ** *

 
*** * * **** ***
* * *** ***** * * *****
* ** * ********* ****** *** * * * ** * * **
* * * *** * * *
** * * *** * *** * (b>=3){
* ** * * ** ** * **** * **
****** * * ***** ** *** ** ** **** ***** * * ** *
** * *** * ** * * *** * * * ***** * * ***** *** * * * ***
** * *** * * *** * * ** * *** * * ** ** * * ** * 0 ;}
* *** *** * *** **
** * * * * ** * **
*** ** * ** *** * *** *

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

 
*** **** * * 0;



}
最新回答 用戶: (-136 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * ***** *

#include ** **** ** *

#define MAX 100



int main(){

char s[MAX];

char c;

int len;

int i;

int pos=0;

int rep=0;
*** * *** * *** * * *

;

len=strlen(s);



while (len <3){
** * ** ** * * ** *
** ***** ** * * **

}


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



for (i=0;i<len;i++){
* * *** ** ** * * * ** ****** **** * * ** (rep==3)
* ** ** *** ******* ** **** ** ** **** * * ** ** * * **** * ****
* **** * * ***  if (s[i]!=s[i-1])
* ** *** * * ***** ** * ** ** * * * * * * ***** * ** * * *** ** * * * * *** * ** ****** * ** ****** * assures that 3 times in a row
* *** ** * * ** ** * if (c==s[i]){
** * ** ** ** * ** ** *** * ** **** * *
** **** * * ** ****** * ** *** *** * *******
* * * * ** ** ** ** * ** * * ** *** * * * ****** * * ** ** ** * ** ** * ** * *** **** ** * * *** *** * the position
* * * * ** * * * * * ** ** * ** *** * if (rep==3)
* * *** * * *** * * *** *** * **** ** ** * ** ** **** ** *
* ** ***** ** * ** **



}


** *** * ** * **





return 0;}
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include ** * *

#define MAX 100



int main(){

char s[MAX];

char c;

int len;

int i;

int pos=0;

int rep=0;
* * *** ** * * * **** *

len=strlen(s);



while (len <3){
* *** ** **** * ** ** * ** * ** * **
** ** * * ** ** *

}


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



for (i=0;i<len;i++){
* * ** * ***** * * * *** ** * ** * * *** ** (rep==3)
**** *** ** ***** * ** * * * **** * * ** * *** ***** ***** *** ** ** *
* * * ** ** ***  if (s[i]!=s[i-1])
* *** ** * *** * ** *** * **** ** * ** * **** * **** * * **** **** **** * * * ** *** ****** * * *** * ** assures that 3 times in a row
** * * **** * ** * ** if (c==s[i]){
* *** * ** * ** * * * ** ******** *
** * ** * ***** *** * * * * * * ** ** ** * *** **
* *** ***** * *** * * ** * * *** * * * * ** *** * *** *** * * * * * * * * * **** * ** * * *** * * ** * ***** the position
* * * ** *** * ** *** ** * ** ** * ****** * * if (rep==3)
* ******* * *** ** * ** * * * ****** ***** * * ***** *** ** * * * *
*** * * ** **** ** *** * * * *



}


** ** ** *** *** *
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include ** * * * *

#define MAX 100



int main(){

char s[MAX];

char c;

int len;

int i;

int pos=0;

int rep=0;
**** ** * *** * **

len=strlen(s);



while (len <3){
** *** * * * * ** ******** ******* *** * *
** * ** * * **

}


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



for (i=0;i<len;i++){
* * * * *** * * *** * ** * ** * *** ** ** * (rep==3)
* * * *** **** ** *** * ** * * * * * * ** * ** ** * * *** **
** *** * *** * * *  if (s[i]!=s[i-1])
* * *** ** ** ** *** ***** * ** ** ** * * *** * **** ** * * ** *** *** *** * * ** * * * * **** ** * * * * ** ** * assures that 3 times in a row
* ***** * **** * * * if (c==s[i]){
* ** ** *** ********* * * ***** * * * * ** *
* * ** ** * **** ** *** *** * * *** * ** ***
**** ** ** ** *** * * * *** * * * * ** * *** ** * * *** * * * * ** **** **** * ****** * *** * ***** *** ** **** * the position
* * ** ** ** ** * ** ** * * * * * if (rep==3)
* * *** * * * * * * ***** **** ** ** **** ** * * * ** ** **
** *** * ** * * * * *



}


** ** * * * ***** * ** *
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ** * * * ** **

#include *** * *** *

#define MAX 100



int main(){

char s[MAX];

char c;

int len;

int i;

int pos=0;

int rep=0;
* * * ** * ** * *** * ** * *

len=strlen(s);



while (len <3){
* ** ** * *** ** ** ** ** ** *
* ** ** * ** ** *

}


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



for (i=0;i<len;i++){
* * ***** * * ** * * * ** *** ** * ** * **** ** (rep==3)
*** * * ** ** * * * ** * * ** ** * * ** ** * **** * * **
** * * *** *  if (s[i]!=s[i-1])
* *** * **** ** ** ** * * ** *** * * *** ** * *** * * * ** * * *** * * * ** ** *** * ******* ** ** ** * * ** * * * assures that 3 times in a row
* * ** ** **** ****** *** * if (c==s[i]){
** * *** * * * ** * * ** * **** ** *****
**** ** ** ** * **** * * *** * *** ** *
** ** ** * * *** **** ** *** * * * *** ** ** * * * * * ***** * ****** * ** ** * ** * * *** ** ** * * * * * the position
*** ** ** * *** * * *** ** ** ** *** if (rep==3)
* * * ** ** ** * * ** **** ** ** ****** ** * ** * * * * * ** **
* ** * ** ** * ***



}


* * *** * ** * *





return 0;}
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#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;

}
最新回答 用戶: (38 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ****** * * *

#include *********

#define MAX 100



int main(){

char s[MAX];

char c;

int len;

int i;

int pos=0;

int rep=0;
* ** **** * ** ** *

;

len=strlen(s);



while (len <3){
* ** ** * ***** * ******** ** * ** **
* *** * * ** * * ****

}


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



for (i=0;i<len;i++){
* *** *** * * * ***** ****** *** ** ** ** (rep==3)
* ********** * * *** ** *** ** ** ** * * ** * *** ** ** * **
***** * * **** * ***  if (s[i]!=s[i-1])
* ** ** ** ** ** * **** * * *** ** ** * * * *** * *** ** ** * ** * *** **** * ** * ** * * * * *** * * * assures that 3 times in a row
* * * * ** ** *********** * if (c==s[i]){
** ** *** *** ** * ***** *** ******** *
** ** * * ** * * * *** **** *** * ** * * *** ****
***** * * * * ** * * * ** ** * * *** * * **** * *** *** * * ** ** * ** * * * * ** * * * * ** * *** ** ***** * ** *** * * ** the position
* * ***** ** *** ** * *** ** ** ** * *** * if (rep==3)
*** *** ** * ** * * * ***** * *** * * * *** ** ** ** ** **
* * ** ****** *** * ***



}


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





return 0;}
最新回答 用戶: (-34 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * **

#include ** * *

#include ** **** * **

int main(){
******* * s[100];
*** * i,a;
** * key ;

 

while (a<3){


** * * * * ** ** * * * ** * * **
** *** * ** * ** strlen(s);



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

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

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

 

}
最新回答 用戶: (-136 分)
0 喜歡 0 不喜歡
內容已隱藏
#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++)

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

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

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

    }







}
最新回答 用戶: (-324 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.108
©2016-2026

相關問題

0 喜歡 0 不喜歡
11 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24270 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.9k 瀏覽
0 喜歡 0 不喜歡
13 回答
[練習] Coding (C) - 最新提問 4月 21, 2017 分類:Midterm |
ID: 24268 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2.9k 瀏覽
0 喜歡 0 不喜歡
47 回答
[考試] 最新提問 4月 13, 2017 分類:Midterm |
ID: 23784 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 8k 瀏覽
0 喜歡 0 不喜歡
8 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24273 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2k 瀏覽
0 喜歡 0 不喜歡
4 回答
[考試] 最新提問 4月 21, 2017 分類:Midterm |
ID: 24272 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.5k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶