C Language Example series-------Eighth day

Source: Internet
Author: User

15, there are 17 people in a circle (numbered 1-17), starting from the 1th number 1, 2, 3 count, where 3 people quit,//the next person from 1 began to count .... Until the last person. What is the number of the person's original position, please? #include <stdio.h>int main () {int P[18]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};int i=1,j=1,k=1,m=17;do {if (P[i]) {if (j++>=3)//reported 1 number {p[i]=0;j=1;m--;} Elsek=i;if (m<=1) break; if (i>=17)//If it is the last element, the next element is p[1]i=1;else//or p[i+1]i++;} while (1);//loop continuously until it is necessary to stop printf ("%d\n", k); return 0;}
16, there is a line of text, asked to delete one of the characters. Both this line of text and the characters to be deleted are entered by the keyboard */* #include <stdio.h>int main () {char Str1[100],str2[100];char ch;int i=0,k=0;printf ("\nplease Input a phase\n "), while ((Str1[i]=getchar ()) = ' \ n ')//assigns a value to the str1 array i++;str1[i]= ' + ';//At the end of the string, add a ' + ' as the end sign printf (" \ Ndelete? "); scanf ("%1s", &ch); for (i=0;str1[i]!= '; i++ ') {if (str1[i]!=ch) str2[i-k]=str1[i];elsek=k+1;} Str2[i-k]= ';p rintf ("\n%s\n", str2); return 0;} *//* #include <stdio.h>int main () {char A[10];char b;int i,j;printf ("Please enter chars:"), gets (a);p rintf ("please Enter Delete char: "); B=getchar (); for (i=0;i<10;i++) {if (a[i]==b) for (j=i;j<10;j++) {a[j]=a[j+1];}} printf ("%s\n", a); return 0;} */


This article from "Peng Brother's Blog" blog, declined reproduced!

C Language Example series-------Eighth day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.