ZOJ 2833-Friendship (query set + optimization)
Friendship
Time Limit: 3 Seconds Memory Limit: 32768 KB
A friend is like a flower,A rose to be exact,Or maybe like a brand new gateThat never comes unlatched.A friend is like an owl,Both beautiful and wise.Or perhaps a friend is like a ghost,Whose spirit never dies.A friend is like a heart that goesStrong until the end.Where wocould we be in this worldIf we didn't have a friend?-By E
;num |= (1 //binary continuous set to 1,11111 respectively indicates that the number between 1,2,3,4,5 can be stored continuouslyNum |= (1 Num |= (1 Num |= (1 Num |= (1 while (num){if (num% 2 = = 0) //binary 1 is continuous, can not be divisible by 2, if divisible, indicating that there are 0 in the binary{ Break ;}num = NUM/2;}if (num = = 0){printf ("a=%d\nb=%d\nc=%d\nd=%d\ne=%d\n", A, B, C, D, e);}}}}}}}return 0;}Results:a=2B=1C=1D=3E=4Please press any key to continue ...This article is from
Output an array to determine if there is a problem, and if so, identify the problem and correct itProgram:#include int Main (){int I, a[5]; for (i = 0; I {A[i] = 0;} for (i = 0; I {printf ("%d\n", A[i]);}return 0;}result: A crash occurred Analysis: The number of loops exceeds the length of the arrayPost-correction procedures:#include int Main (){int I, a[5]; for (i = 0; I {A[i] = 0;} for (i = 0; I {printf ("%d\n", A[i]);}return 0;}Results:00000Please press any key to continue ...This article
Implement a function to print the multiplication table, the number of rows and the number of columns of the table itself specified,Input 9, output 9*9 table, output , output 12*12 multiplication table. Program:#include void mul (int n) //multiplication Multiplication{int I, J; for (i = 1; I n; i++){ for (j = 1; J {printf ("%d*%d=%-2d", I, J, i*j);Where 2 in%2d means output two cells, number backward, that is, right-justified;%-2d, the number is left-justified}printf ("\ n");}}int Main (){int
Stores n integers in the array in reverse order. Solution: Program 1:#include int inv (int x[], int n){int temp, I, j, M = (n-1)/2;for (i = 0; I {j = n-1-I;temp = X[i];X[i] = X[j];X[J] = temp;}Return}int main (){int I, a[10] = {1,2,3,4,5,6,7,8,9,10};printf ("The original array:\n");for (i = 0; i {printf ("%d", a[i]);}printf ("\ n");INV (A, 10);printf ("The array has been inverted:\n");//inverted: Reversefor (i = 0; i {printf ("%d", a[i]);}printf ("\ n");return 0;}Program 2: Using pointer variabl
Enter a positive number less than zero from the keyboard , which requires the output of its square root (if the square root is not an integer, output its integer portion). Requires that the data be checked for a positive number that is less than zero after it is entered . If not, a re-entry is required. Solution: Program:#include #include #define M 1000int main (){int x, y;printf ("Please enter a positive number less than%d x:", M);scanf ("%d", x);while (X>M){printf ("Input data does not meet
input data with scanf, the output of the calculation results require a text description, take the decimal point after 2 digits. the circumference length, circle area, sphere surface area, sphere volume and cylinder volume are obtained. Program:#include int main (){float H,r,c,s,sq,vq,vz;float pi = 3.141526;printf ("Please input circle radius r, Cylinder high H:");scanf ("%f,%f", r,h);c = 2 * PI*R;s = pi*r*r;Sq = 4 * PI*R*R;VQ = (4/3) *pi*r*r*r;VZ = pi*r*r*h;printf ("Circumferential Length: c=%6.
Use the nested invocation of a function to find the largest number in 4 integers. (recursive)Solution: Program:#include int max2 (int a,int b){Return (a > B? a:b);}int max4 (int a, int b,int c,int D){int max2 (int a, int b);Return Max2 (Max2 (Max2 (A, B), c), D);}int main (){int A, b, C,d,max;printf ("Please enter four integer numbers:");scanf ("%d,%d,%d,%d", a, b,c,d);max = Max4 (A, b,c,d);printf ("Max is%d\n", Max);return 0;}Results:Please enter four integer numbers:-1,2,45,2Max is 45Please p
There is a 3*4 matrix that requires the program to find the value of the largest element in it, along with its line number and column number. (Daleitai algorithm)Solution: Program:#include int main (){int I, j, row = 0, Colum = 0, Max;int A[3][4] = {{1,2,3,4},{4,5,6,7},{-1,3,-5,10}};max = a[0][0];printf ("Array a:\n");for (i = 0; I {for (j = 0; J {printf ("%5d", A[i][j]);}printf ("\ n");}for (i = 0; I {for (j = 0; J {if (A[i][j] > Max){max = A[i][j];row = i;Colum = j;}}}printf ("max=%d\nrow=%d\n
; Password:
> @ Error: auth failed on module test
>
> I dont understand this. can somebody explain as to how to acomplish this.
> All suggestions are welcome.
There should be no issues caused by login with your username, try rsync-a max@144.16.251.213: test
Ii. Some useful scripts
These scripts are examples on the rsync Website:
1. Incremental backup of data to the central server every seven days
#! /Bin/sh
# This script does personal backups to a rsync backup server. you will end up
# Wit
Program:#include stdio. h >int Main (){ Double h=+; double t = h/2; Double s=0.0; int i; for (i=1;i10;i+ +){s = s + 2 *T; T = T /2;; // i+1 the height of the ball bounce}s = s +100; // i+1 on landing, it was a total of S m printf ("%lf\n", s);printf ("%lf\n", T); return 0;}Operation Result:299.6093750.097656This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1714537C
Program:#include stdio. h >void Main (){ Double s=0,t=1; double N; for (n=1;n20;n+ +){T = T *(1/N); /// Request 1/(n!) s = s +T; // add items to the cumulative }printf ("%lf\n", s);}Operation Result:1.718282This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1714543C: Ask for 1/n! from 1 to 20 and
1. Procedure:#include stdio . h >enum OS{WIN,LinuxUnix};int Main (){printf ("%d%d%d\n", Win,linux,unix); return 0;}Results:0 1 2NPress any key to continue2. Procedure:#include stdio . h >enum OS{WIN = 1,LinuxUNIX = A};int Main (){printf ("%d%d%d\n", Win,linux,unix); return 0;}Results:1 2 12NPress any key to continueThis article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1716164C Langu
Program 1:#include stdio . h >int Main (){printf ("(Welcome??)" ); return 0;}Results:(Welcome]Press any key to continueThe error is that you should use \? to prevent being parsed into three-letter words, the correct procedure is as follows:Program 2:#include stdio . h >int Main (){printf ("(welcome\?\?)" ); return 0;}Results:(Welcome??)Press any key to continueProcedure 3#include stdio . h >int Main (){printf ("(welcome\\?\\?)" ); return 0;}Results:(welcome\?\?)Press any key to continue
Program: //Four years a run, a century not run, 400 years and run#include int Main (){int i = 0;int count = 0; for (i = {if (i% 4 = = 0 i%!! = 0){printf ("%d", i);count++;} If (i% = = 0){printf ("%d", i);count++;}}printf ("count=%d", count);return 0;}Output Result:10041008101210161020102410281032103610401044 10481052105610601064106810721076108010841088 10921096110411081112111611201124112811321136 11401144114811521156116011641168117211761180 11841188119211961200120412081212121612201224 122812
; \ while ((c = GetChar ())! = EOF c! = ' \ n ') \{\; \}int Main (){int num = 0;Char ch = "' ;scanf ("%d", num);Clear_buf ();scanf ("%c", ch);printf ("Hello bit\n");System ("pause");return 0;}Results:8SHello bitPlease press any key to continue ...Analysis: Program 3 recommended to use, keep using GetChar () gets the characters in the buffer until the obtained C is "\ n" or the end of file is EOF, this method perfectly clears the input buffer and is portableThis article is from the "Rock
Simulates three password entries.Solution: Program:#include #include #include int Main (){int i;Char *p = "123456" ;Char arr[10]; for (i = 0; i {printf ("Please enter password:");scanf ("%s", arr);if (strcmp (P,arr) ==0){ Break ;}Else {printf ("Password error!\n");}}if (i==3){printf ("three times password input error, the system will automatically shut down after 3 seconds!") \ n ");Sleep (3000);}Else if(i{printf ("Congratulations on your successful login!") \ n ");}return 0;}Result 1:Please e
/* For the sum of the first 5 items of sn = a + AA + AAA + AAAA + AAAAA, where A is a number, for example: 2 + 22 + 222 + 2222 + 22222*/#include int main (){int i = 0;int a = 0;int sum = 0;int num=0;scanf ("%d", num);for (i = 0; i {A = a * ten + num;sum = sum + A;}printf ("%d", sum);return 0;}Output Result:224690This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1711998c language; The s
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.