急急急!求解析该C语言python 结束程序语句的个别语句:

问题补充&&
#include&stdafx.h&#include&stdio.h&#include&stdlib.h&#include&string.h&#define OK1#define ERROR0#define TRUE1#define FLASE0//typedef int int_32;typedef struct NOTE{struct NOTE *}Node,*pNtypedef struct{pNodeL}LHint ListInit(LHeart **L){(*L)=(LHeart *)malloc(sizeof(LHeart));(*L)-&List=NULL;(*L)-&count=0;return 0;}int Push(LHeart *L,int data){pNnewdata=(pNode)malloc(sizeof(Node));newdata-&data=newdata-&next=L-&LL-&List=L-&count++;return 0;}int Pop(LHeart *L,int *data){pNode OldDif(L-&count==0)return ERROR;OldData=L-&LL-&List=OldData-&*data=OldData-&free(OldData);L-&count--;return 0;}int StackPrint(LHeart *L){int i=L-&pNode PrintData=L-&Lif(!i)return ERROR;while(PrintData&&i&0){printf(&%d\n&,PrintData-&data);PrintData=PrintData-&i--;}printf(&#######\n&);}int main(){LHeart *ListInit(&mylist);Push(mylist,1);Push(mylist,2);Push(mylist,3);Push(mylist,4);StackPrint(mylist);Pop(mylist,&ret);StackPrint(mylist);system(&pause&);return 0;}...余下全文>>
梁昌仔 &12-17 19:36
•回答
•回答
•回答
•回答
•回答
你的问题呢?
千重沙漏&12-17 19:40
信息来源于互联网,不保证内容的可靠性、真实性及准确性,仅供参考,版权归原作者所有!Copyright &
Powered by谁能帮忙看一下这个C语言程序有错误么,另外求解答,非常感谢。&br/&题目一:编写程序,把560分钟换算成用小时和分钟表示,然后进行输出。&br/&#inciude &stdio.h&&br/&main()&br/&{int m,n;&br/& m=560/60;&br/& n=560/60;&br/& printf(&%d %d&,
谁能帮忙看一下这个C语言程序有错误么,另外求解答,非常感谢。题目一:编写程序,把560分钟换算成用小时和分钟表示,然后进行输出。#inciude &stdio.h&main(){int m,n; m=560/60; n=560/60; printf(&%d %d&,
int h,m;
h=560/60;m=h/60printf("%d %d",h,m)//h为小时,m为分钟
日,错了、h=560/60 ;
m=560-h*60;
你是说加个解释语句就行了?能加下你吗?我在自学C语言,才看到swtich语句
的感言:你就是当代的活雷锋,太感谢了!
其他回答 (2)
代码没有发完全
好久没有学C了,应该是你的类型错了。按照你发的题目,代码只能输出小时,无法输出分钟数
等待您来回答
编程领域专家跪求!!!!!!!!!!!!!!!!最简单的C语言程序 需要100个语句_百度知道
跪求!!!!!!!!!!!!!!!!最简单的C语言程序 需要100个语句
学校要交作业 需要编一个程序 要求最简单的语句 100句& 内容题目随便 越简单越好& 求大虾们帮帮忙。。。。。。。。。。。。。。。急急急急急急急急急急急&&&& 在线等答案
提问者采纳
#include &string.h&#include &stdio.h&#include &math.h&unsigned int i,l1,l2,k,l,num1,num2,num,result,t1,t2,t,co,unsigned int a[100];int b[100];int c[100];char s1[100];char s2[100];char s[100];char r[100];char op[2];void initial();void origco();void judge_sub();void judge_dif();void output();int main(void){
initial();
if (op[0] == '+')
judge_sub();
else if (op[0] == '-')
judge_dif();
system(&pause&); }void initial(){
scanf(&%s&,s1);
scanf(&%s&,op);
scanf(&%s&,s2);l1=strlen(s1); l2=strlen(s2);
num1=num2=0; t1=t2=0; } void origco()
if (s1[0]=='-')
s1[0]='0'; }
if (s2[0]=='-')
s2[0]='0'; }
//negtive numbers for (i=0;i&l1;i++)
num1=num1*10+s1[i]-'0';
for (i=0;i&l2;i++)
num2=num2*10+s2[i]-'0'; printf(&%d %c %d\n&,num1,op[0],num2);
//得到两个数
i=1; num=num1; while (num1&0) {
a[i]=num1%2;
num1=num1/2;
i=i+1; } num1= l1=i;
i=1; num=num2; while (num2&0) {
b[i]=num2%2;
num2=num2/2;
l2=i; num2=
if (l1&l2) l=l1; else l=l2; b[l]=t2; a[l]=t1;
//得到10进制原码
for (i=l1;i&l;i++)
a[i]=0; for (i=l2;i&l;i++)
for (i=l;i&0;i--)
printf(&%d&,a[i]); printf(&\n&);
for (i=l;i&0;i--)
printf(&%d&,b[i]); printf(&\n&);
//2进制原码
}void output (){
printf(&%d&,co);
for (i=l-1;i&0;i--)
printf(&%d&,c[i]);
printf(&\n&);//
if (t==1) printf(&-&);//
printf(&%d\n&,result);
while (result&0)
r[k]=result%10+'0';
result=result/10;
printf(&%d&,result);
for (i=1;i&=k;i++)
s[i]=r[k-i+1];
s[k+1]='\0';
if (t==1) s[0]='-';
s[0]='+';
printf(&%s&,s);}
void judge_sub()
if (t1==t2) {
for (i=1;i&l;i++)
c[i]=a[i]+b[i]+
if (c[i]&=2)
c[i]=c[i]-2;
else co=0;
//if (co==1) printf(&overflow&); } else
if (num1&num2)
for (i=1;i&l;i++)
c[i]=a[i]-b[i]-
if (c[i]&0)
c[i]=c[i]+2;
else co=0;
//if (co==1) printf(&overflow&);
for (i=1;i&l;i++)
c[i]=-a[i]+b[i]-
if (c[i]&0)
c[i]=c[i]+2;
else co=0;
//if (co==1) printf(&overflow&);
for (i=1;i&l;i++)
result=result+c[i]*
power=power*2;
if (co&0) result=result+co*
printf(&overflow\n&);
printf(&%d&,t);}void judge_dif(){
co=0; if (t1==t2) {
if (num1&=num2)
for (i=1;i&l;i++)
c[i]=a[i]-b[i]-
if (c[i]&0)
c[i]=c[i]+2;
else co=0;
//if (co==1) printf(&overflow&);
else if(num1 & num2)
for (i=1;i&l;i++)
c[i]=-a[i]+b[i]-
if (c[i]&0)
c[i]=c[i]+2;
else co=0;
//if (co==1) printf(&overflow&);
for (i=1;i&l;i++)
c[i]=a[i]+b[i]+
if (c[i]&=2)
c[i]=c[i]-2;
else co=0;
//if (co==1) printf(&overflow&); }
for (i=1;i&l;i++)
result=result+c[i]*
power=power*2;
if (co&0) result=result+co*
printf(&overflow\n&);
printf(&%d&,t);}
其他类似问题
按默认排序
其他2条回答
void main(){
printf(&1\n&);
printf(&2\n&);
printf(&3\n&);
printf(&4\n&);
printf(&100\n&);}中间省略号都补上,我相信没有比这个简单的了吧、、、、
#include&stdio.h&main(){
printf(&welcome to china!&);}这绝对是最简单的,凡是学编程的第一个语句一定是它了
c语言程序的相关知识
您可能关注的推广回答者:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁版面简介:C/C++ C语言
总数:25047,共501页
最后更新时间
最后更新时间
总数:25047,共501页一个区间搜索的c语言程序
出问题了 - 程序语言 - 小木虫 - 学术 科研 第一站
&& 查看话题
一个区间搜索的c语言程序
我写了个搜索 大-小-大 区间的程序 ,但最后运行结果始终是错的,不清楚哪里有问题(演算过 逻辑上是正确的)求虫友们帮帮忙
int a,b,x0,x1,x2,h,f0,f1,f2;
printf("please input the number\n");
scanf("x0=%d,h=%d",&x0,&h);
& & h=2*h;
& & x2=x0+h;
& & f2=f(x2);
& & for(f1,f2;f2<f1;f0,f1,f2)
& && && && &x0=x1;
& && && && &x1=x2;
& && && && &x2=x1+h;
& && && && &f0=f(x0);
& && && && &f1=f(x1);
& && && && &f2=f(x2);
& & x2=x0+h;
& & f2=f(x2);
& & for(f0,f2;f2<f0;f0,f1,f2)
& && && && &x1=x0;
& && && && &x0=x2;
& && && && &x2=x0+h;
& && && && &f0=f(x0);
& && && && &f1=f(x1);
& && && && &f2=f(x2);
printf("a=%d,b=%d\n",a,b);
int f(int n)
return 2+n^2;
什么是大小大区间的程序呀,没明白是什么意思,能解释点清楚么,你的代码实在太难看了~:rol: 我曾经编过类似的程序,大 - 小 - 大区间是用来确定凹函数的极值区间的,这段程序是用来求解凹函数的极值区间并求极值的吧,我直接站过来吧
/****************************************************************
*& & & & 名称 :& & & & 确定搜索区间的外推法& && && && && && && && && && && & & & *
*& & & & 说明 :& & & & 假设函数f( x )具有单谷性,即在所考虑的区间内部,&&& & & & *
*& & & & & & & && && & & & 函数f( x )有唯一的极小点x0。为了确定极小点x所在& && & & & *
*& & & & & & & && && & & & 的区间,应使函数f( x )在区间内形成& && &&&& & & & *
*& & & & & & & && && & & & “高-低-高”趋势。& && && && && && && && && && &&&& & & & *
*& & & & 作者 :& & & & ***& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
*& & & & 日期 :& & & &
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
****************************************************************/
/****************************************************
*& & & & 函数声明& & & & & & & & & & & & & & & && && && && && && && && & & & *
****************************************************/
double f( double );
/****************************************************
*& & & & 主函数& & & & & & & & & & & & & & & & & & & && && && && && && && && & & & *
****************************************************/
int main( void )
& & & & double x_1, x_2, x_3;& & & & & & & & & & & & //定义横坐标
& & & & double y_1, y_2, y_3;& & & & & & & & & & & & //定义相应的纵坐标,以减少调用函数的次数,以前没有想到这一点,程序中的重复计算越少越好
& & & && & & & & & & & & & & & & & & & & & & & & & & & //搜索步长
& & & && & & & & & & & & & & & & & & & & & & & & & & & //中间变量
& & & & //初始化搜索
& & & & step = 1;& & & & & & & & & & & & & & & & & & & & & & & & //step的初值对搜索次数影响不大,因为调整时是按照幂次& & & & & & & & & & & & & & & & & & & &
& & & & x_1 = 0;& & & & & & & & & & & & & & & & & & & & & & & & //x_1对搜索次数的影响很大
& & & & y_1 = f( x_1 );
& & & & x_2 = x_1 +
& & & & y_2 = f( x_2 );
& & & & //开始搜索
& & & & if( y_2 > y_1 )& & & & & & & & & & & & & & & & & & & & //调整搜索方向
& & & & & & & & step = -& & & & & & & & & & & & & & & & //C语言中有负号运算符
& & & & & & & & tmp = x_1;& & & & & & & & & & & & & & & & & & & & //对x_1和x_2进行交换
& & & & & & & & x_1 = x_2;
& & & & & & & & x_2 =
& & & & & & & & tmp = y_1;& & & & & & & & & & & & & & & & & & & & //对y_1和y_2进行交换
& & & & & & & & y_1 = y_2;
& & & & & & & & y_2 =
& & & & else& & & & & & & & & & & & & & & & & & & & & & & & & & & & //空语句可以增加程序的易读性
& & & & & & & & ;
& & & & } :tiger39:刚刚没有全选
/****************************************************************
*& & & & 名称 :& & & & 确定搜索区间的外推法& && && && && && && && && && && & & & *
*& & & & 说明 :& & & & 假设函数f( x )具有单谷性,即在所考虑的区间内部,&&& & & & *
*& & & & & & & && && & & & 函数f( x )有唯一的极小点x0。为了确定极小点x所在& && & & & *
*& & & & & & & && && & & & 的区间,应使函数f( x )在区间内形成& && &&&& & & & *
*& & & & & & & && && & & & “高-低-高”趋势。& && && && && && && && && && &&&& & & & *
*& & & & 作者 :& & & & ***& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
*& & & & 日期 :& & & &
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
****************************************************************/
/****************************************************
*& & & & 函数声明& & & & & & & & & & & & & & & && && && && && && && && & & & *
****************************************************/
double f( double );
/****************************************************
*& & & & 主函数& & & & & & & & & & & & & & & & & & & && && && && && && && && & & & *
****************************************************/
int main( void )
& & & & double x_1, x_2, x_3;& & & & & & & & & & & & //定义横坐标
& & & & double y_1, y_2, y_3;& & & & & & & & & & & & //定义相应的纵坐标,以减少调用函数的次数,以前没有想到这一点,程序中的重复计算越少越好
& & & && & & & & & & & & & & & & & & & & & & & & & & & //搜索步长
& & & && & & & & & & & & & & & & & & & & & & & & & & & //中间变量
& & & & //初始化搜索
& & & & step = 1;& & & & & & & & & & & & & & & & & & & & & & & & //step的初值对搜索次数影响不大,因为调整时是按照幂次& & & & & & & & & & & & & & & & & & & &
& & & & x_1 = 0;& & & & & & & & & & & & & & & & & & & & & & & & //x_1对搜索次数的影响很大
& & & & y_1 = f( x_1 );
& & & & x_2 = x_1 +
& & & & y_2 = f( x_2 );
& & & & //开始搜索
& & & & if( y_2 > y_1 )& & & & & & & & & & & & & & & & & & & & //调整搜索方向
& & & & & & & & step = -& & & & & & & & & & & & & & & & //C语言中有负号运算符
& & & & & & & & tmp = x_1;& & & & & & & & & & & & & & & & & & & & //对x_1和x_2进行交换
& & & & & & & & x_1 = x_2;
& & & & & & & & x_2 =
& & & & & & & & tmp = y_1;& & & & & & & & & & & & & & & & & & & & //对y_1和y_2进行交换
& & & & & & & & y_1 = y_2;
& & & & & & & & y_2 =
& & & & else& & & & & & & & & & & & & & & & & & & & & & & & & & & & //空语句可以增加程序的易读性
& & & & & & & & ;
& & & & x_3 = x_2 +& & & & & & & & & & & & & & & & //为了减少代码的长度,应该修改成do...while的形式
& & & & y_3 = f( x_3 );& & & & & & & & & & & & & & & & & & & & //但修改之后,逻辑性不强
& & & & while( y_3 < y_2 )
& & & & & & & & x_1 = x_2;
& & & & & & & & x_2 = x_3;
& & & & & & & & x_3 = x_2 +
& & & & & & & & y_1 = y_2;
& & & & & & & & y_2 = y_3;
& & & & & & & & y_3 = f( x_3 );
& & & & & & & & step = 2 *
& & & & if( x_1 > x_3 )& & & & & & & & & & & & & & & & & & & & //将区间按照从小到大的顺序调整,只需调整两端点
& & & & {& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & //这样调整是为了符合“左小右大”的习惯
& & & & & & & & tmp = x_1;
& & & & & & & & x_1 = x_3;
& & & & & & & & x_3 =
& & & & & & & & tmp = y_1;
& & & & & & & & y_1 = y_3;
& & & & & & & & y_3 =
& & & & printf( "x_1 = %f, x_2 = %f, x_3 = %f\n", x_1, x_2, x_3 );
& & & & printf( "y_1 = %f, y_2 = %f, y_3 = %f\n", y_1, y_2, y_3 );
& & & & return( 0 );& & & & & & & & & & & & & & & & & & & & //返回0,表示程序结束
/********************************************************
*& & & & 函数名称 :& & & & 目标函数& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
*& &输入变量 :& & & & 横坐标x& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & *
*& & & & 输出变量 :& & & & 纵坐标y& &&&& & & & & & & & & & & & & & & & & & & & & & & & & & & & *
*& & & & 说& & 明 :& & & & 目标函数要求具有单谷性& & & & & & & & & & & & & & & & & & & & *
********************************************************/
double f( double x )
& & & & y = x * x - 2 *x + 1;
& & & & return( y );
} #include
int a,b,x0,x1,x2,h,f0,f1,f2;
printf("please input the number\n";
scanf("x0=%d,h=%d",&x0,&h);
& &&&h=2*h;
& &&&x2=x0+h; /*这句逻辑上有问题,应该是x2 = x1 + h,否则x2等于x1,下面的循环从一开始就不会执行*/
& &&&f2=f(x2);
& &&&for(f1,f2;f2<f1;f0,f1,f2) 看到自己以前写的程序,风格实在是太烂了,最近在重新学习C语言,找到了一种更好的风格,刚刚重写了一次,比之前的紧凑很多,分享一下。
& & & & 修改:使用新的代码风格,& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & */
double f(double);
int main(void)
& & & & int& & & & & & & && & & & & & & & & & & & & & & & /*& & & & 变量按照词典的顺序安排& & & & & & & & & & & & & & & & & & & & */
& & & & double& & & &
& & & & double& & & & x_1, x_2, x_3;& & & & & & & & /*& & & & 定义横坐标& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & */
& & & & double& & & & y_1, y_2, y_3;& & & & & & & & /*& & & & 定义相应的纵坐标,以减少调用函数的次数& & & & */
& & & & step = 1;& & & & & & & & & & & & & & & & & & & & /*& & & & 初始化搜索& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & */
& & & & x_1 = 0;& & & & & & & & & & & & & & & & & & & & /*& & & & step按幂次变化,初值对搜索次数影响不大& & & & */
& & & & y_1 = f(x_1);
& & & & x_2 = x_1 +
& & & & y_2 = f(x_2);
& & & & if (y_2 > y_1) {& & & & & & & & & & & & /*& & & & 改变搜索方向& & & & & & & & & & & & & & & & & & & & & & & & & & & & */
& & & & & & & & step = -
& & & & & & & & temp = x_1, x_1 = x_2, x_2 =
& & & & & & & & temp = y_1, y_1 = y_2, y_2 =
& & & & x_3 = x_2 +
& & & & y_3 = f(x_3);
& & & & while (y_3 < y_2) {
& & & & & & & & step *= 2;
& & & & & & & & x_1 = x_2, x_2 = x_3, x_3 = x_2 +
& & & & & & & & y_1 = y_2, y_2 = y_3, y_3 = f(x_3);
& & & & if (x_1 > x_3) {
& & & & & & & & temp = x_1, x_1 = x_3, x_3 =
& & & & & & & & temp = y_1, y_1 = y_3, y_3 =
& & & & printf("x_1 = %f, x_2 = %f, x_3 = %f\n", x_1, x_2, x_3);
& & & & printf("y_1 = %f, y_2 = %f, y_3 = %f\n", y_1, y_2, y_3);
& & & & return 0;
& & & & 函数名称:目标函数f
& & & & 输入变量:横坐标x
& & & & 输出变量:纵坐标y
& & & & 说& & 明 :目标函数要求具有单谷性
& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & */
double f(double x)
& & & & y = x*x - 2*x + 1;
} 楼主,你的程序有几个小问题,给你稍微改了下,仅供参考,测试几个例子,已通过。
int f(int n)
& & & & return 2 + n *
int main()
& & & & int a, b, x0, x1, x2, h, f0, f1, f2;
& & & & printf("please input the number: x0 = ");
& & & & scanf("%d", &x0);
& & & & printf("please input the number: h = ");
& & & & scanf("%d", &h);
& & & & x1 = x0 +
& & & & f1 = f(x1);
& & & & f0 = f(x0);
& & & & if(f1 < f0){
& & & & & & & & x2 = x1+h;
& & & & & & & & f2 = f(x2);
& & & & & & & & while(f2 < f1){
& & & & & & & & & & & & x0 = x1;
& & & & & & & & & & & & x1 = x2;
& & & & & & & & & & & & x2 = x1+h;
& & & & & & & & & & & & f0 = f(x0);
& & & & & & & & & & & & f1 = f(x1);
& & & & & & & & & & & & f2 = f(x2);
& & & & & & & & }
& & & & & & & & a = x1;
& & & & & & & & b = x2;
& & & & else{
& & & & & & & & x2 = x0 -
& & & & & & & & f2 = f(x2);
& & & & & & & & while(f2 < f0){
& & & & & & & & & & & & x1 = x0;
& & & & & & & & & & & & x0 = x2;
& & & & & & & & & & & & x2 = x0-h;
& & & & & & & & & & & & f0=f(x0);
& & & & & & & & & & & & f1=f(x1);
& & & & & & & & & & & & f2=f(x2);
& & & & & & & & }
& & & & & & & & a=x2;
& & & & & & & & b=x1;
& & & & printf("a = %d, b = %d\n", a, b);
& & & & return 0;
} : Originally posted by xqhuang8793 at
楼主,你的程序有几个小问题,给你稍微改了下,仅供参考,测试几个例子,已通过。
#include&stdio.h&
int f(int n)
& & & & return 2 + n *
int main()
& & & & int a, b, x0, x1, x2, h, f0, f1, f ... 非常感谢&&本来想送BB的 但是没找到送的地方 一朵花 聊表感谢哈 : Originally posted by renchong at
非常感谢&&本来想送BB的 但是没找到送的地方 一朵花 聊表感谢哈 没事,互帮互助嘛:hand:
var cpro_id = 'u1216994';
欢迎监督和反馈:本帖内容由
提供,小木虫为个人免费站点,仅提供交流平台,不对该内容负责。欢迎协助我们监督管理,共同维护互联网健康,如果您对该内容有异议,请立即发邮件到
联系通知管理员,也可以通过QQ周知,我们的QQ号为:8835100
我们保证在1个工作日内给予处理和答复,谢谢您的监督。
小木虫,学术科研第一站,为中国学术科研研究提供免费动力
欢迎监督,发现不妥请立即
E-mail: & QQ:8835100

我要回帖

更多关于 增补个别职工代表程序 的文章

 

随机推荐