A. 用c语言怎么写
#include<stdio.h>
struct date
{
int year;
int month;
int day;
};
int days(struct date day)
{
static int day_tab[2][13]=
{{0,31,28,31,30,31,30,31,31,30,31,30,31,}, /*平均每月的天数*/
{0,31,29,31,30,31,30,31,31,30,31,30,31,},
};
int i,lp;
lp=(day.year%4==0&&day.year%100!=0)||day.year%400==0;
/*判定year为闰年还是平年,lp=0为平年,非0为闰年*/
for(i=1;i<day.month;i++) /*计算本年中自1月1日起的天数*/
day.day+=day_tab[lp][i];
return day.day;
}
int main()
{
struct date today,term;
int yearday,year,day;
printf("请输入日期:(年 月 日):");
scanf("%d%d%d",&today.year,&today.month,&today.day); /*输入日期*/
term.month=12; /*设置变量的初始值:月*/
term.day=31; /*设置变量的初始值:日*/
for(yearday=0,year=1990;year<today.year;year++)
{
term.year=year;
yearday+=days(term); /*计算从1990年至指定年的前一年共有多少天*/
}
yearday+=days(today); /*加上指定年中到指定日期的天数*/
day=yearday%5; /*求余数*/
if(day>0&&day<4) printf("打鱼 "); /*打印结果*/
else printf("晒网 ");
}
B. C语言要写在哪里
如果是要考试的话。。。就用TC
2.0。。如果不是为了考试,就用Visual
C++3.0,后边的这个功能多一点。。。
C. 用C语言写。
#include<stdio.h>
intmain()
{
inta,b,h,f,k=1;
scanf("%d%d",&h,&f);
if(h<=0||f<=0)
printf("输入错误!");
else
{
for(a=0;a<=f/2;a++)
for(b=0;b<=f/4;b++)
if(a+b==h&&a*2+b*4==f)
{
k=0;
printf("鸡:%d只,兔%d只 ",a,b);
}
if(k)printf("无解");
}
return0;
}
D. 用C语言写
自己去网上搜!!
E. c语言本身是开源的吗,c语言是用什么写的谢谢大家了
C语言是一个由ISO组织中的ANSI制定的标准,任何个人或者组织都可以根据这个标准将其实现。现今,世界上有许多不同的C语言实现,比较着名的有:GCC、Watcom、MS C等,其中前两者是开源的,后者是闭源的。下面粘贴几个老外的回答(原回答链接)。
The C language is not a piece of software but a defined standard, so one wouldn't say that it's open-source, but rather that it's an open standard.
There are a gazillion different compilers for C however, and many of those are indeed open-source. The most notable example is GCC's C compiler, which is all under the GNU General Public License (GPL), an open-source license.
There are more options. Watcom is open-source, for instance. There is no shortage of open-source C compilers, but without a doubt the most widespread one, at least in the non-Windows world, is GCC.
For Windows, your best bet is probably Watcom or GCC by using Cygwin or MinGW.
C is a standard which specifies how C compilers should generate programs.
C itself doesn't have any source code, just like a musical note doesn't have any plastic.
Some C compilers, such as GCC, are open source.
C is just a language, and a standardised one at that, too. It pretty much is the compiler that "does all the work". Different compilers did have different dialects; before the the C99 ANSI standard, you had things like Borland C and other competing compilers, that implemented the C language in their own fantastic ways.
stdlib is just an agreed-upon collection of standard libraries that are required to be present in any ANSI C implementation.
关于C++开源与否:
与C语言类似,C++也是由ISO/ANSI制定的一个标准,所谓的“官方”并未给出确切的实现,任何组织与个人都可以根据标准自己开发一个C++编译器出来。出名的C++编译器有:GCC/G++、libc/libc++、clang(++)、 Visual studio和MS´ runtime等。也把老外的几个回答贴出来(原回答链接)。
C++ itself is only a description what the language should be,
without a definite implementation.
Anyone can make his own implementations (compiler etc, runtime library, ...)
and call it C++ if it fits to the description.
http://www.open-std.org/jtc1/sc22/wg21/
And if a implementation is open source depends on the creator.
Examples of implementation (parts):
GCC/G++, libc/libc++, clang (++ too), Visual studio and MS´ runtime...
C++ is developed by an ISO standard committee. There's also a C++ foundation that runs a web site you might want to read.
C++ itself is a language, not a specific implementation, so there's no source code available for the standard/language itself.
Some C++ implementations are open source (e.g., Gnu and Clang).
1. C++ is a code standard defined by the International Organization of Standardization (ISO). There are many different implementations of the language, but they all tend to conform to C++11. Unlike Linux or Qt, C++ is just a standard, and to use any code written in the language you'll need a compiler. The major compilers (list from Wikipedia) are LLVM Clang, GCC, Microsoft Visual C++, and the Intel C++ Compiler.
2. C++ revisions are dealt with by ISO, and are influenced primarily by the maintainers of the above four implementations.
3. Clang and GCC are both open-source, I'm sure if you poke around you can find other conforming compilers but those are the two most used.
总之,跟Java、Python和PHP这样所谓的开源语言不同,C语言与C++没有官方提供的各自确切的实现代码(库),ISO/ANSI仅仅提供了C和C++的标准。
这些都是我从自个儿博客摘抄来的,也不见得有人看得到。
F. 怎样用c语言写
染色法。设置染色数组array
初始颜色为各元素各自颜色,即array[i] = i;
在读入学生团体的时候进行“着色”。目的是把学生团体涉及的学生颜色染成同一种颜色。
在染色时发现别的团体的颜色,就把该两种团体的颜色合并。
最后,查找目标编号的学生颜色,在数组中统计该颜色的所有学生即可。
#include <stdio.h>
void color (int * array, int n, int color1, int color2)
{
int i;
for (i = 0; i < n; i++)
if (array[i]==color1)
array[i]=color2;
}
void main()
{
int n, k;
n = 100;
int array [100];
// 初始化染色数组
int i, j, m;
for (i = 0; i < 100; i++)
array [i] = i;
scanf("%d", &k);
int kn;
for (i = 0; i < k; i++)
{
scanf ("%d",&kn);
for (j = 0; j < kn; j++)
{
scanf( "%d", &m);
color (array, n, array[m], n+i);
}
}
scanf ("%d", &j);
for (i = 0; i < 100; i++)
if (array[i]==array[j])
printf ("%d ", i);
printf ("\n");
}
G. C语言是由什么语言编写而成的
我想,你问的是 C语言编译器 是用什么语言写的。
概括说,当今几乎所有的实用的编译器/解释器都是用C语言编写的,有一些语言比如Clojure,Jython等是基于JVM或者说是用Java实现的,IronPython等是基.NET实现的,但是Java和C#等本身也要依靠C/C++来实现,等于是间接调用了C。
世界上第一个C语言编译器,是在B语言基础上,用B语言与PDP汇编语言 编写的。开发过程是先用汇编写了一个最基本功能的子集C0,利用自编译Self-Compile功能,或虚拟机CVM(C Language Virtual Machine)功能,增添新的东西,变C1, 按此法多次增添发展,滚雪球般用汇编把小雪球揉到一起,1生2,2生3,...成了C。C 再生万物。
这里,该向C语言之父Dennis Ritchie(丹尼斯·里奇)致敬。
H. C语言是用什么语言写的
c语言是unix的“副产物”,当时汤姆逊用汇编和“B语言”开发了unix,但由于艰涩难懂,亦不便移植与推广,丹尼斯里奇对“B语言”进行了提炼,猜测可能基于汇编,写出了第一个“C编译器”,并用C语言对unix进行了重写,使得unix可以不依赖具体机器系统,可移植性大增,当然这也归功于C语言的可移植特性。此后C语言由ANSI制定了ANSI
C标准,奠定了现在各种C与类C语言的基础。
I. 用c语言写
int main(void)
{
int n,i,a;
int num=1,num_max=0,main_num;
int S[n];
scanf("%d\n",&n);
for(i=0;i<n;i++){scanf("%d ",&a);S[i]=a;}
for(i=0;i<n;i++)
{
for(a=0;a<n;a++)if(S[i]==S[a])num++;
if(num>num_max){num_max=num;main_num=S[i];}
num=1;
}
return main_num;
}