當前位置:首頁 » 編程語言 » c語言寫的
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言寫的

發布時間: 2022-02-25 14:06:59

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;

}