C language selection and circular computer questions (Part), Computer

Source: Internet
Author: User

C language selection and circular computer questions (Part), Computer

/* (1) the starting prices and billing of 3-kilometer taxis with different license plates in a city are 7 RMB/km in xiali, 2.1 RMB/km outside 3 km, and 8 RMB/km in Fukang, 3 km away, 2.4 yuan/km; Santana, 9 yuan, 3 km away, 2.7 yuan/km. Programming: input the vehicle model and mileage on the keyboard, and output the vehicle resources payable. */
/*
# Include <stdio. h>
Void xiali (double * x );
Void fukang (double * x );
Void sangtana (double * x );

Void main (){
Double m, * x;
Int n;
Printf ("Enter the mileage :");
Scanf ("% lf", & m );
X = & m;
Printf ("the model is (xiali is 1, Fukang is 2, Santana is 3 :");
Scanf ("% d", & n );
Switch (n ){
Case 1: xiali (x); break;
Case 2: fukang (x); break;
Case 3: sangtana (x); break;
}
Printf ("total price: %. 2lf \ n", * x );
}

Void xiali (double * x ){
Double;
A = * x;
If (a <= 3)
* X = 7 *;
Else
* X = 7*3 + 2.1*(A-3 );
}

Void fukang (double * x ){
Double;
A = * x;
If (a <= 3)
* X = 8 *;
Else
* X = 8*3 + 2.4*(A-3 );
}

Void sangtana (double * x ){
Double;
A = * x;
If (a <= 3)
* X = 9 *;
Else
* X = 9*3 + 2.7*(A-3 );
}
*/
/* Write a program that asks the user to type in two integer values at the terminal. test these two number to determine if the first is evenly divisible by the second, and then display an appropriate message at the terminal. */
/*
# Include <stdio. h>
Int panduan (int x, int y );

Void main (){
Int x, y;
Int m;
Printf ("enter two numbers to be judged :");
Scanf ("% d", & x, & y );
M = panduan (x, y );
If (m = 0)
Printf ("% d cannot divide % d \ n", x, y );
Else
Printf ("% d can divide % d \ n", x, y );
}

Int panduan (int x, int y ){
Int flat = 0;
If (x % y = 0)
Flat = 1;
Return flat;
}
*/
/* Write a program. Function: counts the number of integers greater than zero and the number of integers smaller than zero from the integer data that is read. Use input zero to end the input. in the program, use variable I to count the number of integers greater than zero, and use variable j to count the number of integers smaller than zero. */
/*
# Include <stdio. h>
Int duru (int s [], int n );
Void panduan (int s [], int n );
# Define N 20

Void main (){
Int x;
Int shuju [N];
X = duru (shuju, N );
Panduan (shuju, x );
Printf ("the number of integers greater than zero is % d, and the number of integers smaller than zero is % d \ n", shuju [0], shuju [1]);

}

Int duru (int s [], int n ){
Int I;
Printf ("enter a string of numbers :");
For (I = 0; I <n; I ++ ){
Scanf ("% d", & s [I]);
If (s [I] = 0)
Break;
}
Return I;
}

Void panduan (int s [], int n ){
Int m, I, j;
For (m = 0, I = j = 0; m <n; m ++ ){
If (s [m]> 0)
I ++;
Else
J ++;
}
S [0] = I;
S [1] = j;
}
*/
/* Function: outputs an even number that can be divisible by 7 or 17 within 300 based on the number of five entries in each row, and obtains its sum. */
/*
# Include <stdio. h>
Int panduan (int s [], int n );
# Define N 300

Void main (){
Int shu [N], I, j, sum = 0;
J = panduan (shu, N );
For (I = 0; I <j; I ++ ){
Printf ("% 4d", shu [I]);
If (I + 1) % 5 = 0 & I! = 0)
Printf ("\ n ");
Sum + = shu [I];
}
Printf ("\ n % 4d \ n", sum );
}

Int panduan (int s [], int n ){
Int I, j = 0;
For (I = 0; I <n; I ++)
If (I % 2 = 0)
If (I % 7 = 0 | I % 17 = 0)
S [j ++] = I;
Return J-1;
}
*/
/* Calculate the average values of the even and odd numbers in a batch of non-zero integers respectively, and use zero as the termination mark. */
/*
# Include <stdio. h>
Int duru (int s [], int n );
Void panduan (int s [], int n );
# Define N 20

Void main (){
Int x;
Int shuju [N];
X = duru (shuju, N );
Panduan (shuju, x );
Printf ("the average value of an even number is: %. 2f, the average of odd values is: %. 2f \ n ", (float) shuju [0]/(float) shuju [1], (float) shuju [2]/(float) shuju [3]);

}

Int duru (int s [], int n ){
Int I;
Printf ("enter a string of numbers :");
For (I = 0; I <n; I ++ ){
Scanf ("% d", & s [I]);
If (s [I] = 0)
Break;
}
Return I;
}

Void panduan (int s [], int n ){
Int m, I, j, sum1 = 0, sum2 = 0;
For (m = 0, I = j = 0; m <n; m ++ ){
If (s [m] % 2 = 0 ){
I ++;
Sum1 + = s [m];
}
Else {
J ++;
Sum2 + = s [m];
}
}
S [0] = sum1;
S [1] = I;
S [2] = sum2;
S [3] = j;
}
*/
/* Calculate and output the sum of the 10 largest natural numbers that can be divisible by 13 or 17 within 500. */
# Include <stdio. h>
Int panduan (int s [], int n );
# Define N 500

Void main (){
Int shu [N], I, j, sum = 0;
J = panduan (shu, N );
For (I = j; I> J-10; I --){
Printf ("% 4d", shu [I]);
Sum + = shu [I];
}
Printf ("\ n % 4d \ n", sum );
}

Int panduan (int s [], int n ){
Int I, j = 0;
For (I = 0; I <n; I ++)
If (I % 13 = 0 | I % 17 = 0)
S [j ++] = I;
Return J-1;
}

Related Article

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.