一道简单的C语言题,把代码完整写出来行吗,急,谢谢

供稿:hz-xin.com     日期:2025-01-13
一道很简单的C语言题目 11行代码求解。谢谢。谢谢;

你的补充代码是正确的啊,没有错误,我运行过了,一切正常。。。。。我注意到第一段代码的
scanf("%d%d ",a,b);里在第二个%d后边多了一个空格,而补充代码里没有,不知道是不是笔误,当然是不应该有这个空格的。另外,建议在打印语句printf("%d%d",a,b);里加上空格和换行printf("%d %d
",a,b);(你的代码是porint,应该是笔误。。。)

#include #include #include "string.h"int main(int argc, char *argv[]) {char s[50];int i,len;float sum=0;while(1){sum=0.0;printf("
请输入:");fflush(stdin);scanf("%s",s);len=strlen(s);for(i=0;i='A' && s[i]='A' && s[i+1]='0' && s[i+1]<='9'){sum+=(s[i+1]-48)*temp;}}}printf("
分子量为:%.3f",sum);printf("

继续?[y/n]: ");char c;fflush(stdin) ;scanf("%c",&c);if(c!='y' && c!='Y'){break;}}return 0;}

Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_arith.all;
Use ieee.std_logic_unsigned.all;
Entity watch is
Port(sel: out std_logic_vector(6 downto 1) ;
seg:out std_logic_vector(7 downto 0);
Beginstop:in std_logic;
Reset:in std_logic;
Cp2:in std_logic);
End watch;
Architecture behave of watch is
Signal num1: std_logic_vector(3 downto 0);
Signal num2: std_logic_vector(3 downto 0);
Signal num3: std_logic_vector(3 downto 0);
Signal num4: std_logic_vector(3 downto 0);
Signal num5: std_logic_vector(3 downto 0);
Signal num6: std_logic_vector(3 downto 0);
Signal num: std_logic_vector(3 downto 0);
Signal numlet: std_logic_vector(2 downto 0);
Signal count: std_logic_vector(17 downto 1);
Signal selsig: std_logic_vector(6 downto 1);
Signal segsig: std_logic_vector(7 downto 0 );
Signal cp1: std_logic;
Signal cp3: std_logic;
Begin
Process(cp2) ---- 分频。
Begin
If (cp2' event and cp2='1') then
if (Count="1100011010011111")then
count<="00000000000000000"; cp1<=not cp1;
else count<=count+1;
end if;
end if;
cp3<=count(10);
end process;
process(cp1)
begin
if reset ='1' then num1(3 downto 0) <="0000";
num2(3 downto 0) <="0000";
num3(3 downto 0) <="0000";
num4(3 downto 0) <="0000";
num5(3 downto 0) <="0000";
num6(3 downto 0) <="0000";

else if cp1' event and cp1='1' then
if beginstop='1' then num1<=num1+1;
if num1 (3 downto 0)="1001" then
num1 (3 downto 0)<="0000"; num2<= num2+1;
if num2 (3 downto 0)="1001" then
num2 (3 downto 0)<="0000"; num3<= num3+1;
if num3 (3 downto 0)="1001" then
num3 (3 downto 0)<="0000"; num4<= num4+1;
if num4 (3 downto 0)="0101" then
num4 (3 downto 0)<="0000"; num5<= num5+1;
if num5 (3 downto 0)="1001" then
num5 (3 downto 0)<="0000"; num6<= num6+1;
if num6 (3 downto 0)="0101" then
num6(3 downto 0)<="0000";
end if; end if; end if; end if; end if; end if; end if;
end if; end if;
end process;
process (cp3)
begin
if (cp3' event and cp3='1')then
if(numlet(2 downto 0)="000") then
num<=num1;selsig(6 downto 1)<="111110"; end if;
if(numlet(2 downto 0)="001") then
num<=num2;selsig(6 downto 1)<="111101"; end if;
if(numlet(2 downto 0)="010") then
num<=num3;selsig(6 downto 1)<="111011"; end if;
if(numlet(2 downto 0)="011") then
num<=num4;selsig(6 downto 1)<="110111"; end if;
if(numlet(2 downto 0)="100") then
num<=num5;selsig(6 downto 1)<="101111"; end if;
numlet(2 downto 0)<=numlet(2 downto 0)+1;
if(numlet(2 downto 0)="101") then
numlet(2 downto 0)<="011111"; end if;
end if;
if (num (3 downto 0)="0000")then
segsig(7 downto 0)<="01111111"; end if;
if (num (3 downto 0)="0001")then
segsig(7 downto 0)<="00001101"; end if;
if (num (3 downto 0)="0010")then
segsig(7 downto 0)<="10110111"; end if;
if (num (3 downto 0)="0011")then
segsig(7 downto 0)<="10011111"; end if;
if (num (3 downto 0)="0100")then
segsig(7 downto 0)<="11001101"; end if;
if (num (3 downto 0)="0101")then
segsig(7 downto 0)<="11011011"; end if;
if (num (3 downto 0)="0110")then
segsig(7 downto 0)<="11111011"; end if;
if (num (3 downto 0)="0111")then
segsig(7 downto 0)<="00001111"; end if;
if (num (3 downto 0)="1000")then
segsig(7 downto 0)<="11111111"; end if;
if (num (3 downto 0)="1001")then
segsig(7 downto 0)<="11011111"; end if;
end process;
sel<=selsig;
seg(7 downto 0)<=segsig(7 downto 0);
end behave;

设置背景颜色 textbackground(int)
设置字体颜色 textcolor(int)
输出文字 cprintf(*char)

告诉你个小细节,然后具体的还是要自己写
延时 包含头文件#include <windows.h> 函数:Sleep(1000); 参数的单位是毫秒。

菜鸟问一道简单的C语言编程题
return X;} void main(){float a,b,c,area,s;printf("\\nInput a,b,c: ");scanf("%f%f%f",&a,&b,&c);if(a+b>c && a+c>b && b+c>a) \/*判断是否能构成三角形*\/ { s=(a+b+c)\/2;area=sqrt(AREA(s,a,b,c));printf("\\narea=%f\\n",area);} else printf("\\nDat...

一道简单的c语言题目
if(((a==1 && c!=3) || (a!=1 && c==3))&&((b==3 && c!=2) || (b!=3 && c==2))&&((a==2 && c!=3) || (a!=2 && c==3))&&((c==1 && d!=3) || (c!=1 && d==3))){ output = 0; \/\/用来控制是停止循环 break; \/\/如果找到合适的给我停止循...

有两条C语言的题,求详细代码
代码:(1,2在一块)include <stdio.h>#include <stdlib.h>#include int Guess(int magic, int guess){if(magic==guess){return 0;}else if(magic>guess){ \/\/太小return -1;}else{ \/\/太大return 1;}} int SelMax(int a[], int n){int max=a[0],i;for(i=1;i<n;i++){if...

求高手解答一些简单的C语言题目!(高分悬赏)
1、Before GlobalPlusPlus(), it is 1 Before ++, it is 1 After ++, it is 2 After GlobalPlusPlus(), it is 2 2、over!3、(1)printf("Input a year:");scanf("%d",&year);(2)(0==year%4 && 0!=year%100) || 0==year%400 4、(1)s[i]!='\\0'(2)s[j]=s[i];5...

c语言编程
include<stdio.h>#include<math.h>int main(){int n=0,a,b,c,sum;scanf("%d %d",&a,&b);sum=a+b;do{scanf("%d",&c);n++;if(c==sum){printf("Right!\\n");break;}else{if(n<3){printf("Not correct! Try again!\\n");}else{printf("Not correct! You have tried three ...

任意输入n个数,求第k大的数?用C语言,写出完整代码。
int a[10000];int n,temp,i,k,j;printf("请输入你要输入的数的个数n:\\n");scanf("%d",&n);for(i=0;i<n;i++){ printf("a[%d]=",i);scanf("%d",&a[i]);} for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(a[j]...

用C语言写出下题的代码。
{ int c,S;float P,w,d,f;scanf("%f,%f,%d",&P,&w,&S);if(S>=3000)c=12;else c=S\/250;switch(c){ case0∶d=0;break;case1∶d=2;break;case2∶case3∶d=5;break;case4∶case5∶case6∶case7∶d=8;break;case8∶case9∶case10∶case11∶d=10;break;case12∶d=...

求做一道C语言编程题 写出代码,使用多重if else语句
\\n");scanf("%c",&c);if(c<32)printf("%c是控制字符\\n",c);else if(c>=48&&c<=57)printf("%c是数字\\n",c);else if(c>=65&&c<=90)printf("%c是大写字母\\n",c);else if(c>=97&&c<=122)printf("%c是小写字母\\n",c);else printf("%c是其他字符\\n",c);} ...

扑克牌问题(C语言)
= number++;\/\/将扑克赋值 remain--;\/\/手中剩余的牌数减1 order = 1;continue;} order++;j--;} \/\/输出一开始小明手中扑克牌的顺序 for(i = 0; i < 13;i++)printf("%d ",poker[i]);} 想要写出一个程序重点在于理解这个过程,只有对这个过程熟悉了才有可能把它用代码来演示出来。

c语言程序设计试题
【程序1】题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。2.程序源代码:代码如下:include "stdio.h"include "conio.h"main(){ int i,j,k;printf("...