當前位置:編程學習大全網 - 源碼下載 - PPYY軟件源代碼

PPYY軟件源代碼

程序80

題目:沙灘上有壹串桃子,五只猴子將分享它們。第壹只猴子把這堆桃子分成五份,還有壹份。猴子把多出來的壹個扔到海裏,拿了壹個。第二只猴子把剩下的桃子平均分成五份,還有壹份。它還把多出來的那個扔進了海裏,拿走了壹部分。第三只、第四只和第五只猴子也這樣問,沙灘上有多少桃子?

1.程序分析:

2.程序源代碼:

主()

{int i,m,j,k,count

for(I = 4;我& lt10000;i+=4)

{ count = 0;

m = I;

for(k = 0;k & lt5;k++)

{

j = I/4 * 5+1;

I = j;

if(j%4==0)

count++;

其他

打破;

}

I = m;

if(count==4)

{printf("%d\n ",count);

打破;}

}

}

程序81

題目:809*=800*+9*+1,表示兩位數,8*的結果是兩位數,9*的結果是三位數。求代表的兩位數和809*後的結果。

1.程序分析:

2.程序源代碼:

輸出(長b,長I)

{ printf("\n%ld/%ld=809*%ld+%ld ",b,I,I,b % I);

}

主()

{long int a,b,I;

a = 809

for(I = 10;我& lt100;i++)

{ b = I * a+1;

如果(b & gt=1000。& ampb & lt=10000。& amp8 * i & lt100。& amp9 * i & gt=100)

輸出(b,I);}

}

==============================================================

程序82

主題:將八進制轉換為十進制

1.程序分析:

2.程序源代碼:

主()

{ char *p,s[6];int n;

p = s;

gets(p);

n = 0;

while(*(p)!='\0')

{ n = n * 8+* p-' 0 ';

p++;}

printf("%d ",n);

}

==============================================================

程序83

題目:求能由0-7組成的奇數。

1.程序分析:

2.程序源代碼:

主()

{

長和=4,s = 4;

int j;

for(j = 2;j & lt=8;j++)/*j是數字的位置*/ { printf("\n%ld ",sum);

if(j & lt;=2)

s * = 7;

其他

s * = 8;

sum+= s;}

printf("\nsum=%ld ",sum);

}

==============================================================

程序84

題目:偶數總是可以表示為兩個素數之和。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

#i包括“math.h”

主()

{ int a,b,c,d;

scanf("%d ",& ampa);

for(b = 3;b & lt= a/2;b+=2)

{ for(c = 2;c & lt= sqrt(b);c++)

if(b % c = = 0)break;

if(c & gt;sqrt(b))

d = a-b;

其他

打破;

for(c = 2;c & lt= sqrt(d);c++)

if(d % c = = 0)break;

if(c & gt;sqrt(d))

printf("%d=%d+%d\n ",a,b,d);

}

}

==============================================================

程序85

題目:判斷壹個素數能否被幾個9整除。

1.程序分析:

2.程序源代碼:

主()

{ long int m9=9,sum = 9;

int zi,n1=1,C9 = 1;

scanf("%d ",& amp子);

而(n1!=0)

{如果(!(總和%zi))

n 1 = 0;

其他

{ M9 = M9 * 10;

sum = sum+M9;

c9++;

}

}

printf("%ld,可被%d \"9\ "除",sum,C9);

}

==============================================================

程序86

標題:兩個字符串鏈接程序

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

主()

{ char a[]= " acegikm ";

char b[]= " bdfhjlnpq ";

char c[80],* p;

int i=0,j=0,k = 0;

while(a[i]!= ' \ 0 ' & amp& ampb[j]!='\0')

{ if(a[I]{ c[k]= a[I];i++;}

其他

c[k]= b[j++];

k++;

}

c[k]= ' \ 0 ';

if(a[i]=='\0 ')

p = b+j;

其他

p = a+I;

strcat(c,p);

賣出期權(c);

}

==============================================================

程序87

題目:答案結果(結構變量遷移)

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

結構學生

{ int x;

char c;

} a;

主()

{ a . x = 3;

a.c = ' a

f(a);

printf("%d,%c ",a.x,a . c);

}

f(結構學生b)

{

b.x = 20

b.c = ' y

}

==============================================================

程序88

標題:讀取7個整數值(1-50),對於每個讀取的值,程序打印出*的數值個數。

1.程序分析:

2.程序源代碼:

主()

{int i,a,n = 1;

while(n & lt;=7)

做{

scanf("%d ",& ampa);

} while(a & lt;1 | | a >;50);

for(I = 1;我& lt= a;i++)

printf(" * ");

printf(" \ n ");

n++;}

getch();

}

==============================================================

程序89

標題:壹家公司使用公共電話傳輸數據。數據是四位整數,在傳輸過程中加密。加密規則如下:每個數字加5,然後用和除以10的余數替換,再交換第壹位和第四位,第二位和第三位。

1.程序分析:

2.程序源代碼:

主()

{int a,I,aa[4],t;

scanf("%d ",& ampa);

aa[0]= a % 10;

aa[1]= a % 100/10;

aa[2]= a % 1000/100;

aa[3]= a/1000;

for(I = 0;我& lt=3;i++)

{ aa[I]+= 5;

aa[I]% = 10;

}

for(I = 0;我& lt=3/2;i++)

{ t = aa[I];

aa[I]= aa[3-I];

aa[3-I]= t;

}

for(I = 3;我& gt=0;我-)

printf("%d ",aa[I]);

}

==============================================================

節目90

題目:專升本的問題,看成績。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

#定義M 5

主()

{int a[M]={1,2,3,4,5 };

int i,j,t;

I = 0;j = M-1;

while(I { t = *(a+I);

*(a+I)= *(a+j);

*(a+j)= t;

i++;j-;

}

for(I = 0;i printf("%d ",*(a+I));

}

程序91

標題:時間函數1的例子

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

#i包括“time.h”

void main()

{ time _ t lt/*定義壹個長時間變量*/lt = time(NULL);/*系統時間和日期*/printf(ctime(& lt;));/*英文格式輸出*/printf(ASC time(local time(& lt;)));/* transfer to TM */printf(ASC time(gmtime(& lt;)));/*轉換到格林威治時間*/ }

==============================================================

節目92

標題:時間函數示例2

1.程序分析:

2.程序源代碼:

/*計算時間*/ #i包括" time.h "

#包括“stdio.h”

主()

{ time_t開始,結束;

int I;

start=time(空);

for(I = 0;我& lt3000;i++)

{ printf(" \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ n ");}

end=time(空);

printf("\1:不同的是%6.3f\n ",difftime(end,start));

}

==============================================================

節目93

標題:時間函數示例3

1.程序分析:

2.程序源代碼:

/*計算時間*/ #i包括" time.h "

#包括“stdio.h”

主()

{ clock_t start,end

int I;

雙var

start =時鐘();

for(I = 0;我& lt10000;i++)

{ printf(" \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ 1 \ n ");}

end = clock();

printf("\1:不同的是%6.3f\n ",(double)(end-start));

}

==============================================================

節目94

題目:時間函數例4,壹個猜謎遊戲,判斷壹個人的反應速度。

1.程序分析:

2.程序源代碼:

#i包括“time.h”

#包括“stdlib.h”

#包括“stdio.h”

主()

{ char c;

clock_t開始,結束;

time_t a,b;

雙var

int i,猜測;

srand(time(NULL));

printf("妳想玩嗎?(' y '或' n ')\ n ");

循環:

while((c=getchar())=='y ')

{

I = rand()% 100;

printf(" \ n請輸入您猜測的數字:\ n ");

start =時鐘();

a =時間(空);

scanf("%d ",& amp猜測);

而(猜!=i)

{ if(guess & gt;我)

{printf("請輸入小壹點的。\ n ");

scanf("%d ",& amp猜測);}

其他

{printf("請輸入大壹點的。\ n ");

scanf("%d ",& amp猜測);}

}

end = clock();

b =時間(空);

printf("\1:用了妳%6.3f秒\n ",var =(double)(end-start)/18.2);

printf("\1:用了妳%6.3f秒\n\n ",difftime(b,a));

if(var & lt;15)

printf("\1\1妳很聰明!\ 1 \ 1 \ n \ n ");

else if(var & lt;25)

printf("\1\1妳很正常!\ 1 \ 1 \ n \ n ");

其他

printf("\1\1妳真傻!\ 1 \ 1 \ n \ n ");

printf("\1\1祝賀\ 1 \ 1 \ n \ n ");

printf("妳猜的數字是%d ",I);

}

printf(" \ n您想再試壹次嗎?(\"yy\ " .或. \ " n \ ")\ n ");

if((c=getch())=='y ')

轉到循環;

}

==============================================================

節目95

題目:家庭理財小程序

1.程序分析:

2.程序源代碼:

/*資金管理系統*/#包括“stdio.h”

#i包括“dos.h”

主()

{

FILE * fp

結構日期d;

float sum,chm = 0.0

int len,I,j = 0;

int c;

char ch[4]= " ",ch1[16]= " ",chtime[12]= " ",chshop[16],chmoney[8];

PP:clr SCR();

sum = 0.0

gotoxy(1,1);printf(" |-| ");

gotoxy(1,2);printf("|資金管理系統(c 1.0)2000.03 | ");

gotoxy(1,3);printf(" |-| ");

gotoxy(1,4);printf("| -資金記錄- | -今日費用清單-| ");

gotoxy(1,5);printf(" |-|-| ");

gotoxy(1,6);printf(" | date:-| | ");

gotoxy(1,7);printf(" | | | | ");

gotoxy(1,8);printf(" |-| | ");

gotoxy(1,9);printf(" | thgs:-| | ");

gotoxy(1,10);printf(" | | | | ");

gotoxy(1,11);printf(" |-| | ");

gotoxy(1,12);printf(" | cost:-| | ");

gotoxy(1,13);printf(" | | | | ");

gotoxy(1,14);printf(" |-| | ");

gotoxy(1,15);printf(" | | | ");

gotoxy(1,16);printf(" | | | ");

gotoxy(1,17);printf(" | | | ");

gotoxy(1,18);printf(" | | | ");

gotoxy(1,19);printf(" | | | ");

gotoxy(1,20);printf(" | | | ");

gotoxy(1,21);printf(" | | | ");

gotoxy(1,22);printf(" | | | ");

gotoxy(1,23);printf(" |-| ");

I = 0;

getdate(& amp;d);

sprintf(chtime," %4d。%02d。%02d”,d.da_year,d.da_mon,d . da _ day);

for(;;)

{

gotoxy(3,24);printf(" Tab _ _瀏覽費用列表Esc _ _ quit ");

gotoxy(13,10);printf(" ");

gotoxy(13,13);printf(" ");

gotoxy(13,7);printf("%s ",chtime);

j = 18;

ch[0]= getch();

if(ch[0]==27)

打破;

strcpy(chshop," ");

strcpy(chmoney," ");

if(ch[0]==9)

{

mm:I = 0;

fp=fopen("home.dat "," r+");

gotoxy(3,24);printf(" ");

gotoxy(6,4);printf("列出記錄");

gotoxy(1,5);printf(" |-| ");

gotoxy(41,4);printf(" ");

gotoxy(41,5);printf(" | ");

while(fscanf(fp," %10s%14s%f\n ",chtime,chshop,& ampchm)!=EOF)

{ if(i==36)

{ getch();

I = 0;}

如果((I % 36)& lt;17)

{ gotoxy(4,6+I);

printf(" ");

gotoxy(4,6+I);}

其他

if((i%36)>16)

{ gotoxy(41,4+I-17);

printf(" ");

gotoxy(42,4+I-17);}

i++;

sum = sum+CHM;

printf(" % 10s %-14s % 6.1f \ n ",chtime,chshop,CHM);}

gotoxy(1,23);printf(" |-| ");

gotoxy(1,24);printf(" | | ");

gotoxy(1,25);printf(" |-| ");

gotoxy(10,24);printf("total是%8.1f$ ",sum);

fclose(FP);

gotoxy(49,24);printf("按任意鍵…");getch();goto pp

}

其他

{

while(ch[0]!='\r ')

{ if(j & lt;10)

{ strncat(chtime,ch,1);

j++;}

if(ch[0]==8)

{

len = strlen(chtime)-1;

if(j & gt;15)

{ len = len+1;j = 11;}

strcpy(ch1," ");

j = j-2;

strncat(ch1,chtime,len);

strcpy(chtime," ");

strncat(chtime,ch1,len-1);

gotoxy(13,7);printf(" ");}

gotoxy(13,7);printf("%s ",chtime);ch[0]= getch();

if(ch[0]==9)

goto mm

if(ch[0]==27)

退出(1);

}

gotoxy(3,24);printf(" ");

gotoxy(13,10);

j = 0;

ch[0]= getch();

while(ch[0]!='\r ')

{ if(j & lt;14)

{ strncat(chshop,ch,1);

j++;}

if(ch[0]==8)

{ len = strlen(chshop)-1;

strcpy(ch1," ");

j = j-2;

strncat(ch1,chshop,len);

strcpy(chshop," ");

strncat(chshop,ch1,len-1);

gotoxy(13,10);printf(" ");}

gotoxy(13,10);printf("%s ",chshop);ch[0]= getch();}

gotoxy(13,13);

j = 0;

ch[0]= getch();

while(ch[0]!='\r ')

{ if(j & lt;6)

{ strncat(chmoney,ch,1);

j++;}

if(ch[0]==8)

{ len = strlen(chmoney)-1;

strcpy(ch1," ");

j = j-2;

strncat(ch1,chmoney,len);

strcpy(chmoney," ");

strncat(chmoney,ch1,len-1);

gotoxy(13,13);printf(" ");}

gotoxy(13,13);printf("%s ",chmoney);ch[0]= getch();}

if((strlen(chshop)= = 0)| |(strlen(chmoney)= = 0))

繼續;

if((fp=fopen("home.dat "," a+"))!= NULL);

fprintf(fp," %10s%14s%6s ",chtime,chshop,chmoney);

fputc('\n ',FP);

fclose(FP);

i++;

gotoxy(41,5+I);

printf(" % 10s %-14s %-6s ",chtime,chshop,chmoney);

}}}

==============================================================

節目96

主題:計算字符串中子字符串的數量。

1.程序分析:

2.程序源代碼:

#i包括“string.h”

#包括“stdio.h”

主()

{ char str1[20],str2[20],*p1,* p2

int sum = 0;

printf("請輸入兩個字符串\ n ");

scanf("%s%s ",str1,str 2);

p 1 = str 1;p2 = str2

while(*p1!='\0')

{

if(*p1==*p2)

{ while(* p 1 = = * p2 & amp;& amp*p2!='\0')

{ p 1++;

p2++;}

}

其他

p 1++;

if(*p2=='\0 ')

sum++;

p2 = str2

}

printf("%d ",sum);

getch();}

==============================================================

節目97

標題:從鍵盤輸入壹些字符,壹個壹個的發送到磁盤,直到輸入a #。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

主()

{ FILE * fp

char ch,文件名[10];

scanf("%s ",文件名);

if((fp=fopen(文件名,“w”))= = NULL)

{printf("無法打開文件\ n ");

退出(0);}

ch = getchar();

ch = getchar();

而(ch!='#')

{fputc(ch,FP);putchar(ch);

ch = getchar();

}

fclose(FP);

}

==============================================================

節目98

題目:從鍵盤輸入壹個字符串,將所有小寫字母轉換成大寫字母,然後輸出到壹個磁盤文件“test”中保存。輸入的字符串以!開頭!結束。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

主()

{ FILE * fp

字符串[100],文件名[10];

int I = 0;

if((fp=fopen("test "," w"))==NULL)

{ printf("無法打開文件\ n ");

退出(0);}

printf("請輸入壹個字符串:\ n ");

gets(str);

while(str[i]!='!')

{ if(str[I]& gt;= ' a ' & amp& ampstr[I]& lt;='z ')

str[I]= str[I]-32;

fputc(str[i],FP);

i++;}

fclose(FP);

fp=fopen("test "," r ");

fgets(str,strlen(str)+1,FP);

printf("%s\n ",str);

fclose(FP);

}

==============================================================

節目99

標題:有兩個磁盤文件A和B,每個文件有壹行字母。需要將這兩個文件中的信息(按字母順序排列)合並,輸出到壹個新的文件c中。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

主()

{ FILE * fp

int i,j,n,ni;

char c[160],t,ch;

if((fp=fopen("A "," r"))==NULL)

{printf("文件A無法打開\ n ");

退出(0);}

printf("\n A內容為:\ n ");

for(I = 0;(ch=fgetc(fp))!= EOFi++)

{ c[I]= ch;

putchar(c[I]);

}

fclose(FP);

ni = I;

if((fp=fopen("B "," r"))==NULL)

{printf("文件B無法打開\ n ");

退出(0);}

printf("\n B內容為:\ n ");

for(I = 0;(ch=fgetc(fp))!= EOFi++)

{ c[I]= ch;

putchar(c[I]);

}

fclose(FP);

n = I;

for(I = 0;我& ltn;i++)

for(j = I+1;j & ltn;j++)

if(c[I]& gt;c[j])

{ t = c[I];c[I]= c[j];c[j]= t;}

printf("\n C文件是:\ n ");

fp=fopen("C "," w ");

for(I = 0;我& ltn;i++)

{ putc(c[i],FP);

putchar(c[I]);

}

fclose(FP);

}

==============================================================

程序100

題目:有五個學生,每個學生有三門課。從鍵盤輸入以上數據(包括學號、姓名、三門課程),計算平均分。原始數據和計算出的平均分數存儲在磁盤文件“stud”中。

1.程序分析:

2.程序源代碼:

#包括“stdio.h”

結構學生

{ char num[6];

char name[8];

int score[3];

浮動avr

} stu[5];

主()

{int i,j,sum

  • 上一篇:如何註釋html、css、js代碼
  • 下一篇:so格式文件是什麽文件
  • copyright 2024編程學習大全網