百分急求一段简单的C语言程序代码,完成后继续加分 急求!!!C语言编程代码 计费程序:前两分钟0.2元/分钟,...

\u6025\u6c42C\u8bed\u8a00\u7f16\u7a0b \u6c42\u5982\u4e0b\u5206\u6bb5\u51fd\u6570\u7684\u503c

#include double y(double x) {if (x <= 0) return 3 - x;else if (x < 1) return 1 + x * x;else return 2 * x + sqrt(x);}

#include int main(){int sec=0,min;printf("input seconds: ");min=sec/60 ;if ( sec % 60 )min+=1;if ( min <=2 )printf("%.1f\n", min*0.2 );elseprintf("%.1f\n", (min-2)*0.1+0.4 );return 0; }

第一部分:
#include<stdio.h>

main()
{
int s,i;
s=0;
for(i=0;5*i+4<=1001;i++)
{
s+=5*i+4;
}
printf("%d\n",s);
}

第二部分:
#include<stdio.h>

main()
{
int n,i,j;
printf("Input n:");
scanf("%d",&n);
for(i=n;i>0;i--)
{
for(j=0;j<i;j++)
printf("*");
printf("\n");
}
}

第三部分:
#include<stdio.h>

main()
{
int n,s,i,t;
printf("Input n:");
scanf("%d",&n);
t=1;
s=0;
for(i=1;i<=n;i++)
{
t*=i;
s+=t;
}
printf("s=%d\n",s);
}

第四部分:
#include <stdio.h>
#include <conio.h>
main()
{
int option=0; /*选择用变量,use to record user's press*/
float celsius; /*摄氏温度,she shi wen du*/
float fahrenheit; /*华氏温度,hua shi wen du*/

while(option!=3)
{
printf("1 for Fahrenheit to Celsius;\n");
printf("2 for Celsius to Fahrenheit;\n");
printf("3 to quit.\n");
printf("Please to choose: ");

scanf("%d",&option);
printf("\n");
if(option==1)
{
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32)*5/9;
printf("The Fahrenheit %f in Celsius is %f\n",fahrenheit,celsius);
}

if(option==2)
{
scanf("%f",&celsius);
fahrenheit=(celsius*9/5)+32;
printf("The Celsius %f in Fahrenheit is %f\n",celsius,fahrenheit);
}

printf("Press any key to continue...\n");
getch(); /*pause for screen, press any key to continue*/
clrscr();
}/*end While*/

}/*end main*/

参考下吧

第一部分:
#include
"stdio.h"
int
main()
{
int
sum
=
0,
n
=
1;
while
(5*n+4
<=
1001)
{
sum
+=
5*n+4;
n++;
}
printf("%d\n",
sum);
return
0;
}
第二部分:
#include
"stdio.h"
int
main()
{
int
n;
printf("please
input
the
number
n:
");
while
(scanf("%d",
&n)
&&
n
!=
0)
{
while
(n>0)
{
for
(int
i=1;
i<=n;
i++)
printf("*");
printf("\n");
n--;
}
printf("\n");
printf("please
input
the
number
n:
");
}
return
0;
}
第三部分:
#include
"stdio.h"
int
main()
{
long
s
=
0,
t;
int
n;
printf("please
input
the
number
n:
");
scanf("%d",
&n);
while
(n
>
0)
{
t
=
1;
for
(int
i=1;
i<=n;
i++)
t
*=
i;
s
+=
t;
n--;
}
printf("the
sum
is:
%ld\n",
s);
return
0;
}
第四部分:
#include
<stdio.h>
#include
<conio.h>
void
main()
{
int
option=0;
/*选择用变量,use
to
record
user's
press*/
int
celsius;
/*摄氏温度,she
shi
wen
du*/
int
fahrenheit;
/*华氏温度,hua
shi
wen
du*/
while
(option!=3)
{
printf("1
for
Fahrenheit
to
Celsius;\n");
printf("2
for
Celsius
to
Fahrenheit;\n");
printf("3
to
quit.\n");
printf("Please
to
choose:
");
scanf("%d",&option);
printf("\n");
if
(option
==
1)
{
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32)*5/9;
printf("The
Fahrenheit
%f
in
Celsius
is
%f\n",fahrenheit,celsius);
}
else
if(option
==
2)
{
scanf("%f",&celsius);
fahrenheit=(celsius*9/5)+32;
printf("The
Celsius
%f
in
Fahrenheit
is
%f\n",celsius,fahrenheit);
}
printf("Press
any
key
to
continue...");
getch();
/*pause
for
screen,
press
any
key
to
continue*/
clrscr();
}
}

1.
//---------------------------------------------------------------------------

#include <stdio.h>

long int fun(int i)
{
return (5*i+4);
}
int main(void)
{
long int s=0;
int i=0;
while (fun(i)<=1001)
s+=fun(i++);
printf("%ld\n",s);
return 0;
}
//---------------------------------------------------------------------------

2.
//---------------------------------------------------------------------------

#include <stdio.h>

int main(void)
{
int i,j,n;
do{
printf("n=");
scanf("%d",&n);
if (n>20||n<=0) {
printf("0<n<=20\n");
}
}while (n<=0||n>20);
for (i = 0; i<n; i++) {
printf("%*c",(2*i)/2+1,'*');
for (j=1; j<2*(n-i)-1; j++) {
putchar('*');
}
putchar('\n');
}
return 0;
}
//---------------------------------------------------------------------------

3.
//---------------------------------------------------------------------------

#include <stdio.h>
#include <assert.h>
long int fun(int n)
{
if (n>1) {
return n*fun(n-1);
}
else return n;
}
int main(void)
{
int i;
double s=0;
scanf("%d",&i);
assert(i>0&&i<=20);
while (i>0)
s+=fun(i--);
printf("%.0lf",s);
return 0;
}
//---------------------------------------------------------------------------

4.

/*Replace this with your Student-Number.*/
/*这个程序是进行温度转换*/
/*This program is to alter in Fahrenheit and Celsius*/
/*Modify this program's error*/
#include <stdio.h>
#include <conio.h>
void main()
{
int option=0; /*选择用变量,use to record user's press*/
float celsius; /*摄氏温度,she shi wen du*/
float fahrenheit; /*华氏温度,hua shi wen du*/

while(option!=3){
printf("1 for Fahrenheit to Celsius;\n");
printf("2 for Celsius to Fahrenheit;\n");
printf("3 to quit.\n");
printf("Please to choose: ");

scanf("%d",&option);
printf("\n");
if (option==1) {
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32)*5/9;
printf("The Fahrenheit %f in Celsius is %f\n",fahrenheit,celsius);
}
else if(option==2){
scanf("%f",&celsius);
fahrenheit=(celsius*9/5)+32;
printf("The Celsius %f in Fahrenheit is %f\n",celsius,fahrenheit);
}
printf("Press any key to continue...");
getch(); /*pause for screen, press any key to continue*/
clrscr();
}/*end While*/

}/*end main*/

第一部分:
#include "stdio.h"
int main()
{
int sum = 0, n = 1;
while (5*n+4 <= 1001)
{
sum += 5*n+4;
n++;
}
printf("%d\n", sum);
return 0;
}

第二部分:
#include "stdio.h"
int main()
{
int n;
printf("please input the number n: ");
while (scanf("%d", &n) && n != 0)
{
while (n>0)
{
for (int i=1; i<=n; i++)
printf("*");
printf("\n");
n--;
}
printf("\n");
printf("please input the number n: ");
}
return 0;
}

第三部分:
#include "stdio.h"
int main()
{
long s = 0, t;
int n;
printf("please input the number n: ");
scanf("%d", &n);
while (n > 0)
{
t = 1;
for (int i=1; i<=n; i++)
t *= i;
s += t;
n--;
}
printf("the sum is: %ld\n", s);
return 0;
}

第四部分:
#include <stdio.h>
#include <conio.h>
void main()
{
int option=0; /*选择用变量,use to record user's press*/
int celsius; /*摄氏温度,she shi wen du*/
int fahrenheit; /*华氏温度,hua shi wen du*/

while (option!=3)
{
printf("1 for Fahrenheit to Celsius;\n");
printf("2 for Celsius to Fahrenheit;\n");
printf("3 to quit.\n");
printf("Please to choose: ");

scanf("%d",&option);
printf("\n");

if (option == 1)
{
scanf("%f",&fahrenheit);
celsius=(fahrenheit-32)*5/9;
printf("The Fahrenheit %f in Celsius is %f\n",fahrenheit,celsius);
}
else if(option == 2)
{
scanf("%f",&celsius);
fahrenheit=(celsius*9/5)+32;
printf("The Celsius %f in Fahrenheit is %f\n",celsius,fahrenheit);
}

printf("Press any key to continue...");
getch(); /*pause for screen, press any key to continue*/
clrscr();
}
}

  • 鐧惧垎鎬ユ眰涓娈电畝鍗曠殑C璇█绋嬪簭浠g爜,瀹屾垚鍚庣户缁姞鍒
    绛旓細绗竴閮ㄥ垎锛歩nclude "stdio.h"int main(){ int sum = 0,n = 1;while (5*n+4 <= 1001){ sum += 5*n+4;n++;} printf("%d\n",sum);return 0;} 绗簩閮ㄥ垎锛歩nclude "stdio.h"int main(){ int n;printf("please input the number n:");while (scanf("%d",&n)&& n != 0...
  • C璇█缂栫▼棰;鎬ユ眰浠g爜?
    绛旓細绋嬪簭婧愪唬鐮佸強杩愯缁撴灉濡備笅锛歩nclude <stdio.h> int main(){ int i,j,a[25];for(i=0; i<5; i++)for(j=0; j<5; j++)a[i*5+j]=(i+1)*(j+1);for(i=0; i<25; i++)printf("%3d%c",a[i],i%5==4?'\n':',');return 0;} ...
  • 鎬ユ眰:涓閬绠鍗曠殑C璇█缂栫▼
    绛旓細main(){ FILE *fp,*result;char ch='\0';char word[1000][20]; /* 鏈澶氬瓨1000涓笉鍚屽崟璇嶏紝姣忎釜鍗曡瘝鍦20涓瓧绗﹀唴銆 */ int count_word[1000]={0}; /* 姣忎釜鍗曡瘝瀵瑰簲涓暟 */ int i=0,j=0,k=0,flag=2,total=0;float percent; /* 姣忎釜鍗曡瘝鍑虹幇棰戠巼 */ clrscr();if(((fp=fope...
  • 鎬ユ眰涓娈礐璇█绋嬪簭
    绛旓細define MSG "涓鍦板湪瑕佸伐" /*璁$畻缁撴灉涓虹悊鎯冲兼椂杈撳嚭鐨勬枃瀛楋紝鍙互鍦ㄦ淇敼*/ int cp(const int a,const int b,const char c){ switch (c) { default: return -1;case '+':return a+b;case '-':return a-b;case '*':return a*b;case '/':return b?a/b:-1;} } int main(...
  • 姹C璇█缂栫▼浠g爜,鎬ユ眰鈥︹
    绛旓細void main(void){ int red=4,white=5,yellow=7,//璁板綍鍚勪釜鐞冪殑涓暟,i,j,k;for(i=1;i<=red;i++){ for(j=1;j<=white;j++){ for(k=1;k<=yellow;k++){ if((i+j+k)==5) //鍒ゆ柇鏉′欢 printf("red:%d, white:%d, yellow:%d\n",i,j,k);} } } } //浜,鍔犳补鍝!
  • 鎬ユ眰涓涓300鈥斺400琛鐨凜璇█浠g爜,鍝釜澶х鑳界粰涓晩??浠涔绋嬪簭閮芥垚...
    绛旓細婧愪唬鐮佲斺C璇█瀹炵幇鎵撳嵃鏉ㄨ緣涓夎(婧愪唬鐮)鏉ㄨ緣涓夎褰㈡槸褰㈠锛1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 鐨勪笁瑙掑舰锛屽叾瀹炶川鏄簩椤瑰紡(a+b)鐨刵娆℃柟灞曞紑鍚庡悇椤圭殑绯绘暟鎺掓垚鐨勪笁瑙掑舰锛屽畠鐨勭壒鐐规槸宸﹀彸涓よ竟鍏ㄦ槸1锛屼粠绗簩琛岃捣锛屼腑闂寸殑姣忎竴涓暟鏄笂涓琛岄噷鐩搁偦涓や釜鏁颁箣鍜屻
  • 鎬ユ眰C璇█澶х甯繖缂栧啓绋嬪簭,涓嶄細寰堝鏉,杩囩▼瑕佸噯纭缁,楹荤儲浜!_鐧惧害...
    绛旓細include <stdio.h>#include <conio.h>#define ARRAY_LEN 100 /*鏁扮粍闀垮害*/int numToDigit (int num, int arr[]) {int remain,i=1,j=0,count=0;int temp[ARRAY_LEN];while (num) { remain = num % 10; /*闄や互10鍙栦綑鏁帮紝浠ュ彇鍑烘渶鍚庝竴浣嶆暟瀛*/ num /= 10; /*闄や互10鍙栨暣鏁...
  • 鎬ユ眰c璇█缂栫▼
    绛旓細int main(){ double max,min,aver=0;double a[9];for(int i=0;i<8;i++)scanf("%lf",&a[i]);max=min=a[0];for(int i=0;i<8;i++){ if(a[i]>max)max=a[i];//璁板綍鏈澶у if(a[i]<min)min=a[i];//璁板綍鏈灏忓 } for(int i=0;i<8;i++)if(a[i]!=min&&a...
  • 姹備竴涓c璇█绋嬪簭
    绛旓細include <stdlib.h> include "string.h"typedef struct{ char word[20];int count;}WORD;int find(char* source, char target){ int i,j;int s_len=strlen(source);for(i=0;i<s_len;i++){ baiif(source[i]==target){ return i;} } return -1;} char* right(char* source,int ...
  • 鍦ㄧ嚎绛墌鎬ユ眰鍐欎釜C璇█绋嬪簭!!!
    绛旓細/* 娴嬭瘯绋嬪簭 */ int main(){ CirQueue Q;int input = 0; /* 鍏ラ槦鏁版嵁锛岀敱鐢ㄦ埛杈撳叆*/ /* 鍒濆鍖栭槦鍒 */ initQueue(&Q);printf("璇疯緭鍏ュ叆闃熸暟鎹:\n");/* 鍏ラ槦鎿嶄綔 */ while(!QueueFull(&Q)){ scanf("%d\n", &input);EnQueue(&Q, input);} printf("鍑洪槦鏁版嵁:\n");/* 鍑...
  • 扩展阅读:学编程一年大概多少钱 ... plc编程必背50个程序 ... c++入门程序代码 ... 初学编程必背50个 ... 扫一扫题目出答案 ... 零基础免费学编程 ... c十十编程要学多久 ... 最难学的10大语言 ... 编程必背100个代码 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网