/* (1) A city of different license plate taxi 3 km starting price and billing are: Xiali 7 yuan/km, 3 km away 2.1 yuan/km, Fukang 8 yuan/km, 3 km away 2.4 yuan/kilometer, Santana 9 Yuan, 3 km away 2.7 yuan/km. Programming: Enter the car model and the number of kilometres from the keyboard, and output the fare payable. */
/*
#include <stdio.h>
void Xiali (double *x);
void Fukang (double *x);
void Sangtana (double *x);
void Main () {
Double m,*x;
int n;
printf ("Please enter the number of kilometres travelled:");
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);
Case 2:fukang (x);
Case 3:sangtana (x);
}
printf ("Total Price:%.2lf\n", *x);
}
void Xiali (double *x) {
Double A;
A=*x;
if (a<=3)
*x=7*a;
Else
*x=7*3+2.1* (a-3);
}
void Fukang (double *x) {
Double A;
A=*x;
if (a<=3)
*x=8*a;
Else
*x=8*3+2.4* (a-3);
}
Void Sangtana (double *x) {
double A;
a=*x;
if (a<=3)
*x=9*a;
Else
*x=9*3+2.7* (a-3);
}
/*
/*write a program that asks the user to type in and the integer values at the terminal. Test these the 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 ("Please enter two number to judge:");
scanf ("%d%d", &x,&y);
M=panduan (x, y);
if (m==0)
printf ("%d cannot be divisible by%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 the program. Function: From the integer data read, the number of integers greater than 0 and the number of integers less than 0 is counted. Using the input zero end input, the program uses the variable I to count the number of integers greater than 0, using the variable J to count the number of integers less than 0. */
/*
#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 0 is:%d, the number of integers less than 0 is:%d\n", shuju[0],shuju[1]);
}
int Duru (int s[],int n) {
int i;
printf ("Please enter a serial number:");
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: Output 300 or more of the number of 5 numbers per line can be divisible by 7 or 17, and to find its and. */
/*
#include <stdio.h>
int Panduan (int s[],int n);
#define N
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;
}
*/
/* Find the average number of even and odd numbers in a non-zero integer, and use 0 as the terminating token. */
/*
#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 number of even values is:%.2f, the odd average is:%.2f\n ", (float) shuju[0]/(float) shuju[1], (float) shuju[2]/(float) shuju[3]);
}
int Duru (int s[],int n) {
int i;
printf ("Please enter a serial number:");
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;
}
//
/* calculates and outputs the sum of the maximum 10 natural numbers that can be divisible by 13 or 17 within 500. */
#include <stdio.h>
int Panduan (int s[],int n);
#define N
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;
}
C language selection and cycle-on-machine topics (part)