www.5129.net > C语言whilE查表程序

C语言whilE查表程序

用数组来解决最简单方便,自己参考一下吧#include <stdio.h>int main(){ char ch; int i,j,BQ; char * k1[3][4]={ {"0","0.1","0.2-0.3" ,"0.4-0.6"} , {"0.1" ,"0.2-0.3","0.4-0.6","0.7-0.9"} , {"0.2","0.4-0.6","0.7-0.9","1.0"} , };

#include "stdio.h" void main() { float a[10] = {29.4,33.3,37.2,41.4,45.8,50.4,55.2,60.2,65.6}; int b,c; printf("请输入温度: "); scanf("%d",&b); if(b%10!=0||b<0||b>80) { printf("输入错误"); } else { c=b/10; printf("温度是: %.1f",a[c]); } }

这个粗略了点,而且还有Bug. 即:输入字母会出问题. #include <stdio.h> main() { int temperature = 0; float solubility = 0.0; while(1) { clrscr(); temperature = 0; solubility = 0.0; printf("input temperature: \r\n"); scanf("%d", &temperature); if(

#include<stdio.h> struct data {int t; float m; }; struct data a[]={{0,29.4},{10,33.3},{20,37.2},{30,41.4},{40,45.8},{50,50.4},{60,55.2},{70,60.2},{80,65.6}}; void main() { int n,i; scanf("%d",&n); for(i=0;i<9;i++) if(a[i].t==n) {printf("%3.1f\n",a[i].m); break; } } 这个简单~

void main() { int i; char st[2]; int nn = 4; char str_tab[][2]={"a","d","s","f"}; unsigned int tab[][5]={ {0x16,0x1a,0x1a,0x1e,0x02}, {0x0c,0x12,0x32,0x3e,0x02}, {0x1a,0x16,0x16,0x16,0x00}, {0x00,0x12,0x3e,0x32,0x30} }; printf("please enter a

当n==1时执行while循环结构里的语句,当n不等于1时,则跳过该循环执行循环体外的语句.while 循环的格式:while (表达式){语句;} while 循环的执行顺序:当表达式为真,则执行下面的语句,语句执行完之后再判断表达式是否为真,如果

while()是先判断括号里面的是否成立,成立执行方法体内的语句. do while()是先执行方法体内语句再判断,do while()至少执行一次. #include void main(){ int sum=0,i; scanf("%d",&i); while(i void main(){ int sum=0,i; scanf("%d",&i); do{ sum=sum+i; i++; } while(i

main() { int i; while(i<10)i++; printf("%d",i); } 这就是个while语句了.够简单了吧

亲,这个不是通常C语言的语法,是嵌入式C的语法,你这个应该是单片机之类的程序吧.这里的while循环的作用其实就是等待P1_3引脚的低电平结束的(注意,循环的执行条件是(P1IN & BIT3)==0x00,也就是只要P1_3引脚电平为低,循环就持续执行,当引脚电平为高时,跳出循环,执行A2=(A2+1)%2).

用数组和查表.例如 输入 s 则输出:0x1A,0x16,0x16,0x16,0x00 void main() { int i; char st[2]; int NN = 4; char str_tab[][2]={"a","d","s","f"}; unsigned int tab[][5]={ {0x16,0x1A,0x1A,0x1E,0x02},{0x0C,0x12,0x32,0x3E,0x02},{0x1A,0x16,0x16,

网站地图

All rights reserved Powered by www.5129.net

copyright ©right 2010-2021。
www.5129.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com