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H$r;HMQ$7$F$_$k(B
$B2rEz(B
\Windows $B$,I=<($5$l$k!#(B
$B2?$bI=<($5$l$J$$!#(B
abc $B$,I=<($5$l$k!#(B
\windows $B$,I=<($5$l$k!#(B
$B;HMQ5vBz>r7o$,I=<($5$l$k!#(B
($B%$%s%9%H!<%k$5$l$F$$$l$P(B)$B%=%j%F%#%"$H$$$&%2!<%`$,F0$/(B
MS-DOS $B%W%m%s%W%H$,>C$($k!#(B
[$B1i=,(B] $B
$BEz(B
3. $BBh;M2s(B
$B%o!<%I$N1i=,(B
$B!V%-!<%\!<%I$d%^%&%9$KBe$k
$BMWE@(B
$B2rEzNc(B
4. $BBh8^2s(B
$B1i=,(B1
$BNc(B
Excel $B$N1i=,(B
5. $BBhO;2s(B
$B1i=,(B1
$BMWE@(B
$B2rEzNc(B
$BBg3X$K9g3J$9$k$K$O!D!D(B
$B;vL3E*$J
$B3X=,$9$k>e$G$NCm0UE@(B
$B9)IW$7$?$3$H(B
$B1i=,(B2
/* This program prints "Hello World!". */
#include <stdio.h>
main(){
printf("Hello World!\n");
}
$B2rEz(B
$B1i=,(B4
$B2rEz(B
#include <stdio.h>
main(){
printf("Hello New World!\n");
}
$B1i=,(B5
$B2rEz(B
2.000000 x^2 + 3.000000 x + 1.000000 = 0
root1= -0.500000, root2= -1.000000
$BC"$7!"$3$N%W%m%0%i%`$O!"
zitsubu= -b/2/a; kyobu = sqrt(d)/2/a;
$B$3$l$O
zitsubu= -b/2/a; kyobu = sqrt(-d)/2/a;
6. $BBh<72s(B
$BNcBj(B
#include <stdio.h>
main(){
int i;
float a;
i=1;
i=i+1;
a=0.314E1;
printf("%d %f\n",i,a);
}
$B2rEz(B
2 3.140000
$B1i=,(B
$B2rEz(B
det = ad - bc
$B$H$9$k!#(B
det
$B$,(B 0 $B$G$J$$$H$-!"(B x, y $B$O
$B(#(Bx$B($(B 1 $B(#(B d -b $B($(#(B e $B($(B
$B("(B $B("(B = --- $B("(B $B("("(B $B("(B
$B(&(By$B(%(B det $B(&(B -c a $B(%(&(B f $B(%(B
$B=>$C$F!"(B x=(de-bf)/det, y=(-ce+af)/det $B$G$"$k!#(B
7. $BBhH,2s(B
$B1i=,(B8-1
int a[10]={4,5,3,1,7,8,9,2,0,6};
$B2rEz(B
#include <stdio.h>
main()
{
int a[10]={4,5,3,1,7,8,9,2,0,6};
int i,sum;
float heikin;
sum=0;
i=0;
while(i<10){
sum=sum+a[i];
i=i+1;
}
heikin=sum/10.0;
printf("%x\n",heikin);
}
$B1i=,(B8-2
$B2rEz(B
#include <stdio.h>
main()
{
int a[10]={4,5,3,1,7,8,9,2,0,6};
int i,sum;
float heikin;
sum=0;
for(i=0;i<10;i++){
sum+=a[i];
}
heikin=sum/10.0;
printf("%d\n",heikin);
}
$B1i=,(B8-3
$B2rEz(B
#include <stdio.h>
main()
{
int i;
for(i=1;i<=100;i++){
printf("%d\n",i);
}
}
$B1i=,(B8-4
($B@5$NJ?J}:,$O(B sqrt() $B$K$h$j7W;;$G$-$k(B)
$B2rEz(B
#include <stdio.h>
main()
{
int a[10]={4,5,3,1,7,8,9,2,0,6};
int i,sum,dsum;
float heikin,bunsan,hyouzyunhensa
sum=0;
dsum=0;
for(i=0;i<10;i++){
sum+=a[i];
dsum+=a[i]*a[i];
}
heikin=sum/10.0;
bunsan=dsum/10.0-heikin*heikin;
hyouzyunhensa=sqrt(bunsan);
printf("%f\n",hyouzyunhensa);
}
$B1i=,(B8-5
$BJP:9CM(B = ($BCM(B-$BJ?6Q(B)*10/$BI8=`JP:9(B + 50
$B2rEz(B
#include <stdio.h>
main()
{
int a[10]={4,5,3,1,7,8,9,2,0,6};
int i,sum,dsum,hensachi;
float heikin,bunsan,hyouzyunhensa,
sum=0;
dsum=0;
for(i=0;i<10;i++){
sum+=a[i];
dsum+=a[i]*a[i];
}
heikin=sum/10.0;
bunsan=dsum/10.0-heikin*heikin;
hyouzyunhensa=sqrt(bunsan);
for(i=0;i<10;i++){
hensachi=(a[i]-heikin)*10.0/hyouzyunhensa+50;
printf("$BE@?t(B: %d $BJP:9CM(B:%d\n",a[i],hensachi);
}
}
$B1i=,(B8-6
$B2rEz(B
#include <stdio.h>
main(){
int i,num;
char a[]=" This is a sample sentence.";
printf("%s\n",a);
i=0;
while(a[i]==' '){
i=i+1;
}
printf("There are %d spaces in front of the string.\n",i);
}
$B1i=,(B8-7
$B2rEz(B
#include <stdio.h>
main(){
int i,num;
char privious;
char a[]=" This is a sample sentence.";
printf("%s\n",a);
i=0;
num=0;
privious=' ';
while(a[i]!='\0'){
if(privious==' '){
if(a[i]!=' '){num=num+1;}
}
privious=a[i];
i=i+1;
}
printf("This string has %d words.\n",num);
}
8. $BBh6e2s(B
$B1i=,(B9-1
$B2rEz(B
#include <stdio.h>
main(){
printf("abcdefg\n");
}
$B1i=,(B9-2
int i=23;
$B2rEz(B
The value of i is 23.
#include <stdio.h>
main(){
int i=23;
printf("The value of i is %d.\n",i);
}
$B1i=,(B9-3
float x=0.314E1;
$BJQ?t(B x $B$NCM$O(B 3.14000.
$B2rEz(B
#include <stdio.h>
main(){
float x=0.314E1;
printf("$BJQ?t(B x $B$NCM$O(B %f.\n",x);
}
$B1i=,(B9-4
char c='a';
$BJ8;zJQ?t(B c $B$NCM$O(B 'a' $B$G$"$k!#(B
$B2rEz(B
#include <stdio.h>
main(){
char c='a';
printf("$BJ8;zJQ?t(B c $B$NCM$O(B '%c' $B$G$"$k!#(B",c);
}
$B1i=,(B9-5
char s[]="abcdefg";
$BG[NsJQ?t(B s $B$OJ8;zNs$H$7$F(B abcdefg $B$H$$$&CM$r;}$D!#(B
$B2rEz(B
#include <stdio.h>
main(){
char s[]="abcdefg";
printf("$BG[NsJQ?t(B s $B$OJ8;zNs$H$7$F(B %s $B$H$$$&CM$r;}$D!#(B",s);
}
$B1i=,(B9-6
int i=3;
$B2rEz(B
#include <stdio.h>
main(){
int i=3;
if(i>0){
printf("$B@5$NCM(B\n");
}else if(i<0){
printf("$BIi$NCM(B\n");
}else{ /* i==0 */
printf("$BNm(B\n");
}
}
$B1i=,(B9-7
float a=3.0;
float b=6.0;
a x + b = 0
$B2rEz(B
#include <stdio.h>
main(){
float a=3.0;
float b=6.0;
float x;
x=-b/a;
printf("%f\n",x);
}
$B1i=,(B9-8
float a=3.0;
float b=6.0;
a x + b = 0
$B2rEz(B
#include <stdio.h>
main(){
float a=3.0;
float b=6.0;
float x;
if(a==0){
if(b==0){
printf("The equation %d x + %d = 0 holds for any x.\n",a,b);
}else{
printf("The equation %d x + %d = 0 can not hold for any x.",a,b);
printf(" That is, this has no root.\n");
}
}else{
x=-b/a;
printf("The root of the equation %d x + %d =0 is %f\n",a,b,x);
}
}
$B1i=,(B9-9
int n=50;
$B2rEz(B
#include <stdio.h>
main(){
int n=50;
int i;
for(i=1;i<=n;i++){
printf("%i\n",i);
}
}
$B1i=,(B9-10
int n=50;
1+2+3+...+n
$B2rEz(B
#include <stdio.h>
main(){
int n=50;
int i,sum;
sum=0;
for(i=1;i<=n;i++){
sum+=i;
}
printf("%d\n",sum);
}
$B1i=,(B9-11
int a[10]={5,4,2,0,1,9,7,3,8,6};
$B2rEz(B
#include <stdio.h>
main(){
int a[10]={5,4,2,0,1,9,7,3,8,6};
int i;
for(i=0;i<10;i++){
printf("%d\n",a[i]);
}
}
$B1i=,(B9-12
int a[10]={5,4,2,0,1,9,7,3,8,6};
$B2rEz(B
#include <stdio.h>
main(){
int a[10]={5,4,2,0,1,9,7,3,8,6};
int i,sum;
sum=0;
for(i=0;i<10;i++){
sum+=a[i];
}
printf("%d\n",sum);
}
$B1i=,(B9-13
float x[10]={5.0,4.0,2.0,0.0,1.0,9.0,7.0,3.0,8.0,6.0};
$B2rEz(B
#include <stdio.h>
main(){
float x[10]={5.0,4.0,2.0,0.0,1.0,9.0,7.0,3.0,8.0,6.0};
float sum,average;
int i
sum=0.0;
for(i=0;i<10;i++){
sum+=x[i];
}
average=sum/10.0;
printf("%f\n",average);
}
$B1i=,(B9-14
int k=6;
char a[]="This is a sample string.";
$B2rEz(B
#include <stdio.h>
main(){
int k=6;
char a[]="This is a sample string.";
printf("%c\n",a[k+1]);
}
$B1i=,(B9-15
char a[]="This is a sample string.";
$B2rEz(B
#include <stdio.h>
main(){
char a[]="This is a sample string.";
int i;
i=0;
while(a[i]!='\0'){
i++;
}
printf("%d\n",i);
}
$B1i=,(B9-16
char a[]="This is a sample string.";
$B2rEz(B
#include <stdio.h>
main(){
char a[]="This is a sample string.";
int i;
i=0;
while(a[i]!='\0'){
i++;
}
while(i>=0){
printf("%c",a[i]);
i--;
}
}
$B1i=,(B9-17
char c='i';
char a[]="This is a sample string.";
$B2rEz(B
#include <stdio.h>
main(){
char c='i';
char a[]="This is a sample string.";
int i,num;
num=0;
for(i=0;a[i]!='\0';i++){
if(a[i]==c){
num++;
}
}
printf("%d\n",num);
}
$B1i=,(B9-18
$B2rEz(B
char c='m';
char a[]="This is a sample string.";
#include <stdio.h>
main(){
char c='m';
char a[]="This is a sample string.";
int i;
i=0;
while(a[i]!=c){
i++;
}
printf("%d\n",i+1);
}
$B1i=,(B9-19
char a[]="-123";
int i;
$B2rEz(B
#include <stdio.h>
main(){
char a[]="-123";
int i;
int j,hugou;
i=0;
hugou=1;
for(j=0;a[j]!='\0';j++){
if(a[j]=='0'){
i=i*10;
}else if(a[j]=='1'){
i=i*10+1;
}else if(a[j]=='2'){
i=i*10+2;
}else if(a[j]=='3'){
i=i*10+3;
}else if(a[j]=='4'){
i=i*10+4;
}else if(a[j]=='5'){
i=i*10+5;
}else if(a[j]=='6'){
i=i*10+6;
}else if(a[j]=='7'){
i=i*10+7;
}else if(a[j]=='8'){
i=i*10+8;
}else if(a[j]=='9'){
i=i*10+9;
}else if((a[j]=='-')&&(hugou==1)){
hugou=-1;
}
}
i=i*hugou;
printf("%d\n",i);
}
$B1i=,(B9-20
char a[]="-123.02";
float x;
$B2rEz(B
#include <stdio.h>
main(){
char a[]="-123.02";
float x;
float div;
int j,hugou;
i=0;
hugou=1;
for(j=0;(a[j]!='\0')&&(a[j]!='.');j++){
if(a[j]=='0'){
x=x*10;
}else if(a[j]=='1'){
x=x*10+1;
}else if(a[j]=='2'){
x=x*10+2;
}else if(a[j]=='3'){
x=x*10+3;
}else if(a[j]=='4'){
x=x*10+4;
}else if(a[j]=='5'){
x=x*10+5;
}else if(a[j]=='6'){
x=x*10+6;
}else if(a[j]=='7'){
x=x*10+7;
}else if(a[j]=='8'){
x=x*10+8;
}else if(a[j]=='9'){
x=x*10+9;
}else if((a[j]=='-')&&(hugou==1)){
hugou=-1;
}
}
if(a[j]=='.'){
j++;
div=10.o;
while(a[j]!='\0'){
/* the case that a[j]=='0' is omitted */
if(a[j]=='1'){
x=x+1/div;
}else if(a[j]=='2'){
x=x+2/div;
}else if(a[j]=='3'){
x=x+3/div;
}else if(a[j]=='4'){
x=x+4/div;
}else if(a[j]=='5'){
x=x+5/div;
}else if(a[j]=='6'){
x=x+6/div;
}else if(a[j]=='7'){
x=x+7/div;
}else if(a[j]=='8'){
x=x+8/div;
}else if(a[j]=='9'){
x=x+9/div;
}
j++;
div*=10;
}
}
x=x*hugou;
printf("%f\n",x);
}
9. $BBh==2s(B
$B1i=,(B10-1
#include <stdio.h>
main()
{
int i,sum;
sum=0;
for(i=0;i<50;i=i+1){
sum=sum+i;
}
printf("%d\n",sum);
}
$B2rEz(B
#include <stdio.h>
main()
{
int i,sum;
sum=0;
for(i=0;i<50;i++){
sum+=i;
}
printf("%d\n",sum);
}
$B1i=,(B10-2
#include <stdio.h>
main()
{
int i,j;
i=0;
j=(i=i+1);
printf("i=%d, j=%d\n",i,j);
j=(i+=1);
printf("i=%d, j=%d\n",i,j);
j=(i++);
printf("i=%d, j=%d\n",i,j);
j=(++i);
printf("i=%d, j=%d\n",i,j);
}
$B2rEz(B
$B7k2L(B
i=1, j=1
i=2, j=2
i=3, j=2
i=4, j=4
i++ $B$H(B ++i $B$N0c$$(B
$B1i=,(B10-3
#include <stdio.h>
main()
{
char a[]="100101";
int i,x;
x=0;
for(i=0;a[i]!='\0';i++){
if(a[i]=='0'){
x*=2;
}else{
if(a[i]=='1'){
x=x*2+1;
}
}
}
printf("%s(2) = %d(10)\n",a,x);
}
$B2rEz(B
$B%W%m%0%i%`$N@bL@(B
#include <stdio.h>
main()
{
char a[]="100101";
int i,x;
x=0;
for(i=0;a[i]!='\0';i++){
if(a[i]=='0'){
x*=2;
}else if(a[i]=='1'){
x=x*2+1;
}
}
printf("%s(2) = %d(10)\n",a,x);
}
$B1i=,(B10-4
#include <stdio.h>
main()
{
char c;
while((c=getchar())!=EOF)
{
putchar(c);
}
}
$B2rEz(B
abc
abc
def
def
$B1i=,(B10-5
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
do{
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c;
}
c=getchar();
}
line[i]='\0';
printf("%s\n",line);
}while(c!=EOF);
}
$B2rEz(B
10. $BBh==0l2s(B
$B1i=,(B11-1
$B2rEz(B
#include <stdio.h>
main(){
char c;
int i;
i=0;
while((c=getchar())!=EOF){
i++;
}
printf("%d\n",i);
}
$B1i=,(B11-2
$B2rEz(B
#include <stdio.h>
main(){
char c;
int i;
i=0;
while((c=getchar())!=EOF){
if(c=='a'){
i++;
}
}
printf("%d\n",i);
}
$B1i=,(B11-3
$B2rEz(B
#include <stdio.h>
main(){
char c;
int i;
i=0;
while((c=getchar())!=EOF){
if(c=='a'){
c='A';
}
putchar(c);
}
}
$B1i=,(B11-4
$B2rEz(B
#include <stdio.h>
main(){
char c;
int i;
i=1;
while((c=getchar())!=EOF){
if(c=='\n'){
i++;
}
}
printf("%d\n",i);
}
$B1i=,(B11-5
$B2rEz(B
#include <stdio.h>
main(){
char c;
int i;
i=0;
while((c=getchar())!=EOF){
if(c=='\n'){
putchar('\n');
}
putchar(c);
}
}
$B1i=,(B11-6
$B2rEz(B
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
int j;
j=1;
do{ /* do{ $BJ8(B } while($B>r7o(B); $B$K4X$7$F$O8e=R(B */
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c; /* line[i] $B$K(B c $B$rF~$l$?8e!"(B i $B$r0l$DA}$d$9(B */
}
c=getchar();
}
line[i]='\0'; /* $B9T$N:G8e$KJ8;zNs$N=*$j$NJ8;z$rF~$l$k(B */
if(j==3){
printf("%s\n",line);
}
j++;
}while((c!=EOF)||j>3);
}
$B1i=,(B11-7
$B2rEz(B
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
int j,find;
do{ /* do{ $BJ8(B } while($B>r7o(B); $B$K4X$7$F$O8e=R(B */
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c; /* line[i] $B$K(B c $B$rF~$l$?8e!"(B i $B$r0l$DA}$d$9(B */
}
c=getchar();
}
line[i]='\0'; /* $B9T$N:G8e$KJ8;zNs$N=*$j$NJ8;z$rF~$l$k(B */
find=0;
for(j=0;line[j]!='\0';j++){
if(line[j]=='a'){
find=1;
break;
}
}
if(find){
printf("%s\n",line);
}
}while(c!=EOF);
}
$B1i=,(B11-8
$B2rEz(B
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
int j;
do{ /* do{ $BJ8(B } while($B>r7o(B); $B$K4X$7$F$O8e=R(B */
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c; /* line[i] $B$K(B c $B$rF~$l$?8e!"(B i $B$r0l$DA}$d$9(B */
}
c=getchar();
}
line[i]='\0'; /* $B9T$N:G8e$KJ8;zNs$N=*$j$NJ8;z$rF~$l$k(B */
for(j=0;(j<3)&&(line[j]!='\0');j++){
putchar(line[j]);
}
putchar('\n');
}while(c!=EOF);
}
$B1i=,(B11-9
$B2rEz(B
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
int j;
do{ /* do{ $BJ8(B } while($B>r7o(B); $B$K4X$7$F$O8e=R(B */
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c; /* line[i] $B$K(B c $B$rF~$l$?8e!"(B i $B$r0l$DA}$d$9(B */
}
c=getchar();
}
line[i]='\0'; /* $B9T$N:G8e$KJ8;zNs$N=*$j$NJ8;z$rF~$l$k(B */
for(j=0;line[j]==' ';j++){
}
printf("%d\n",j);
}while(c!=EOF);
}
$B1i=,(B11-10
$B2rEz(B
#include <stdio.h>
#define BUFSIZE 1000
main()
{
char c;
char line[BUFSIZE];
int i;
int j;
int space=0;
do{ /* do{ $BJ8(B } while($B>r7o(B); $B$K4X$7$F$O8e=R(B */
i=0;
c=getchar();
while((c!=EOF)&&(c!='\n')){
if(i<BUFSIZE-1){
line[i++]=c; /* line[i] $B$K(B c $B$rF~$l$?8e!"(B i $B$r0l$DA}$d$9(B */
}
c=getchar();
}
line[i]='\0'; /* $B9T$N:G8e$KJ8;zNs$N=*$j$NJ8;z$rF~$l$k(B */
for(j=0;j<space;j++){
if(line[j]!=' '){
break;
}
}
while(line[j]!='\0'){
putchar(line[j++]);
}
for(space=0;line[space]==' ';space++){
}
}while(c!=EOF);
}
$B1i=,(B11-11
$B2rEz(B
#include <stdio.h>
main(){
int x;
scanf("%d",x);
printf("\n%d\n",x+1);
}
$B1i=,(B11-12
$B2rEz(B
#include <stdio.h>
main(){
int x,y;
scanf("%d",x);
scanf("%d",y);
printf("\n%d\n",x+y);
}
$B:dK\D>;V(B [email protected]