【指标公式网源码】【tproxy源码】【wexposed源码】case统计源码_case代码
1.求C语言源代码 题目 学生成绩管理系统
2.Cè¯è¨ç»¼å设计
3.求一个小型学生理财系统的统计面向对象程序设计的源代码
4.用java编程:输入一个16位的长整型数,利用swith语句统计其中一到九每个数字出现的次数
5.求一个c++小程序源代码,要求200行以上,源码指标公式网源码给100分,代码tproxy源码能用再加100
求C语言源代码 题目 学生成绩管理系统
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc,统计wexposed源码 char *argv[])
{ #define UP
#define DOWN
#define INSERT
#define DEL
#define ENTER
#define KEY
#define KEY
#define KEY
#define KEY
#define KEY A
#define KEY B
#define KEY C
#define KEY D
#define KEY E
#define KEY F
#define KEY G
#define KEY H
#define KEY I
#define KEY K
#define KEY L
#define KEY M
#define KEY N
#define KEY O
#define KEY P
#define KEY Q
#define KEY R
#define KEY S
#define KEY T
#define KEY U
#define KEY V
#define KEY W
#define KEY X
#define KEY Y
#define KEY Z
#define ALT F2
#define ALT F6
#define CTRL 4
#define SHIFT 1
#define ESC 1
#define BACKSPACE
#define LEN sizeof(struct student)
/*菜单选项。下拉标志*/
int menu x yes=1;
int menu y yes=0;
int menu x=1;
int menu x old=0;
int menu y1=1,源码咸鱼 源码 menu y3=1;
/*保存文件名*/
char filename[]="NONAME.dat";
/*开辟保存数据的空间*/
void *buf=0;
int left,top,right,bottom;
/*开辟保存数据的空间*/
struct student
{ long num;
char name[];
float h maths;
float english;
float c;
float sum;
int s sum;
struct student*next;
};
struct student*head=0,*p1,*p2;
int record n;
char key buf[];
long student number=0;
char student name[];
float student score=0;
/*读键扫描码*/
char get key(void)
{ AH=0; int (0X); return( AH); }
/*显示字符*/
void show char(char z)
{ AL=z; AH=0x0e; int (0x);}
/*测试是否有键输入*/
int key pressed(void)
{ AH=0x0b; int (0x); if( AL==0) return(0); else return(1);}
/*退出程序*/
voidquit(void)
{ void free data(void);void restore menu(void); free data();
restore menu(); window(1,1,,,0x0f);
cur show(); gotoxy(1,1); exit(1);
}
/*回到dos提示符*/
void os shell(void)
{ void mainmenu show(void);
window(1,1,,,0x0f);
cur show(); gotoxy(1,1); system("");
mainmenu show();
}
/*主窗口文字*/
void main menu 1(void)
{ int i,j; char*p;
char*mainmenu word[]={ "File ","Save ","Options ","About me"};
if(menu x!=menu x old||!menu y yes)
{ p=mainmenu word[0];
putstr(4,1,0x,p,);
for(i=0;i<;i++) if(*p++<='Z') putchar(i+4,1,*(p-1),0x);
p=mianmenu word[0];
if(menu x yes)
for(i=0;j=0;i<;i++)
{ it('A'<=*p&&*(p+1)=='')break;
putchar(i+4,1,*p,0x0f); }
p++; }
}
}
void main menu 2(void)
{ int i; int len; char *p;
char*mainmenu word[6]={ "F1-Help","F2-Save","F5-OS shell","F-Menu","Message"};
void main box(void); main box();
p=mainmenu word[0]; putstr(2,,0x,p,);
for(i=0;i<;i++) { if(*p=='F'||('0'<=*p&&*p<='9'))putchar(i+2,*p,0x); p++; }
p=mainmenu word[4]; putstr(,,0x,p,9); len=strlen(filename);
putchar(-len/2-1,2,'',0x);
for(p=filename,i=0;*p!=0;p++;i++) putchar(-len/2+i,2,*p,0x);
putchar(-len/2+len,2,'',0x);
}
/*主窗口线框*/
void main box(void)
{ int i;
for(i=1;i<=;I++) { putchar(i,2,,0x); putchar(i,,,0x);putchar(i,,,0x);}
for(i=1;i<=;i++) { putchar(1,i,,0x); putchar(,i,,0x); }
putchar(1,2,,0x); putchar(,2,,0x); putchar(1,,,0x);
putchar(,,,0x); putchar(1,,,0x); putchar(,,,0x);
}
/*显示主窗口菜单*/
voidmianmenu show (void)
{ textmode set(); cur hide();
window(1,1,,,0x1e);
window(1,1,,1,0x);
window(1,,,,0x);
main menu ; main menu ;
}
/*显示下拉菜单*/
void menu show (void)
{ int i;
char*submenu word[][5]={ { "New file F4","Open file F3","OS shell F5","Quit Alt-X"},
p"Input F6","Delete F8","Update F9","query F","Sort F"}};
switch(menu x)
{ case 1:
if(menu x!=menu x old)
{ menu x old=menu x; menu window(3,2,,8); menu box(3,2,,8,3,0);}
for(i=0;i<2;i++)
{ putstr(4,3+i,0x,submenu word[0][i],);
putchar(5,3+i,*(submenu word[0][i]+1),0x); }
for(i=3;i<5;i++) putstr(4,3+i,0x7-,submenu word[0][i-1],);
putchar(6,6,*(submenu word[0][2]+2),0x);
putchar(5,7,*(submenu word[0][3]+1),0x);
window(4,2+menu y1,,2+menu y1,0x0f);
if(menu y1<=2)
putstr(4,2+menu y1,0x0f,submenu word[0][menu y1-1],);
else
putstr(4,2+menu y1,0x0f,submenu word[0][menu y1-2],); break;
case 2:menu x old=menu x; menu window(,2,,8);}
for(i=0;i<5;i++)
{ putstr(,3+i,0x,submenu word[1][i],);
putchar(,3+i,*(submenu word[1][i]+1,0x); }
window(,2+menu y3,,2+menu y3,0x0f);
putstr(,2+menu y3,0x0f,submenu word[1][menu y3-1],); break;
case 4:menu x old=menu x; }
}
/*清空键盘缓冲*/
void clr buf(void){ key buf[1]=0;}
void free data(void)
{ struct student*pa,*pb;
if(head)
{ pb=pa=head;
do{ pb=pa; pa=pb->next; free(pb);}while(pa!=0);head=0; }
}
/*姓名处理*/
int string name(void)
{ int i,j;
if(key buf[1]==0) return(0);
for(i=2,j=0;i<=key buf[1]+1;i++;j++)
student name[j]='\0'; return(1);}
/*输入数据*/
voidinput(int flag)
{ int i; char*s1="NO. Name H maths English C\\C++ ";
char*s2=" | | | | ";
char*title="INPUT"; menu window(,,,); window(,,,,0x);
putstr(,,0x,title,7); putstr(,,0x,s1,);
if(head==0)
{ head=p1=p2=(struct student*)malloc(LEN);if(!head)memory error();
p1->next=0;
else{
for(p1=head,record n=0;p1!=0;record n++)
{ p2=p1; p1=p2->next; }
p1=(struct student*)malloc(LEN);
if(!p1)memory error();
p2->next=p1; }
while(1)
{ record n++; putstr(,,0x,s2,);
if(flag==1)
{ gotoxy(,); printf("Record%d",record n); }
do{ window(,,,,0x);
if(!getstring(,,))goto out ;
}while(!getstring number());
p1->num=student number;
do{ if(!getstring(,,)) goto out;
}while(!string name());
strcpy(pi->name,student name);
for(i=1;i<=3;i++)
{ do{ window(+(i-1)*8,,0x);
if(!getstring(+(i-1)*8,,5)) gotoout;
}while(!string score());
if(i==1)p1->h maths=student score;
if(i==2)pi->english=student score;
if(i==3)p1->c=student score; }
p1->sum=0.0; p1->s num=0;
if(flag==2){ record n--;goto out;}
p2=p1;
p1=(struct student*)malloc(LEN);
if(!p1)memory error();
p1->next=0; p2->next=p1; }
out: cur hide(); window(,,,,0x1e);
if(flag==1) { if(head==p1)head=0; free(p1); p2->next=0; info(1); record n--; }
menu x yes=1; main menu 1();
}
/*查看是否有该成绩*/
struct student* search(int flag)
{ struct student8pa,*pb; if(head==0)return(0); pb=pa=head;
if(flag==1)
{ if(head->num==student number) return(head-1);
do{ if(pa->num==student number) return(pb);
pb=pa; pa=pb->next;} while(pa!=0); }
return (0);
}
/*查询,删除,代码fundebug源码修改对话框*/
struct student*msg box(int which)
{ int flag; int key; char*p="<-A B->"; menu window(,统计,,); gotoxy(,);
printf("Number OR Name"); window(,,,,0x); gotoxy(,);
printf(" | "); gotoxy(,);
switch(which)
{ case 1:printf("Delete");break;
case 2:printf("Update");break;
case 3:printf("Query");break; }
do{ while(!key pressed())
now time();
key=get key(); if(key==KEY A) { flag=1;break;}
if(key==KEY B) { flag=2;break;} printf("\");
}while(1);
putstr(,,0x,p,7);
if(flag==1)
{ do{
gotoxy(,); printf(" | "):
if(!getstring(,,)) goto out;
}while(!string number());
window(,,,,0x1e); return(search(1)); }
else
{ do{ gotoxy(,); printf(" | ");
if(!getstring(,,)) goto out;
}while(!string name());
window(,,,,0x1e); return(0);}
/*删除记录*/
void delete(void)
{ struct student*pa,*pb; pb=msg box(1); if(pb==0)info(3);
else
{ if(pb==(head-1))
{ pb=head; if(pb->next==0) head=0;
else head=pb->next; }
else
{ if(pb->next->next==0) { pb->next=pa; } }
record n--; info(2); }}
/*删除记录*/
void update(void)
{ int i; struct student*p; i=record n; p=msg box(2;
if(p==0)info(3);
else
{ input(2);
if(i==record n)
{ if(p==(head-1)){
head->num=p1->num; strcpy(head->name,p1->name);
head->h maths=p1->h maths; head->english=p1->english;
head->c=p1->c; free(p1); p2->next=0; }
else { p->next->num=p1->num; strcpy(p->next->name,p1->name);
p->next->h maths=p1->h maths; p->next->english=p1->english;
p->next->c=p1->c; free(p1); p2->next=0; }
info(4); }
else { record n--;p2->next=0;free(p1);info(5);} }}
/*查询成绩*/
void query(void)
{ struct student*p,*pa,*pb; int key ,flag,i,j;
char*str="NO. Name H matns English C\\C++ Sum S NO.";
char*sm="NO. Name h maths English C\\C++ (who fails)";
menu window(,,,); gotoxy(,); printf("Find Fail");
putchar(,,'A',0xe4); putchar(,,'B',0xe4);
do{ if(!key pressed()) now time();
key=get key();
if(key==KEY A){ flag=1;break;}
if(key==KEY B){ flag=2;break;}
printf("\"); }while(1);
window(,,,,0x1e); if(flag==1)
{ p=msg box(3); if(p==0) info(3);
else{ window(6,5,,,0x0e); window(5,4,,,0x5e); window(6,5,,,0x0e);
putstr(,4,0x5a,str,); gotoxy(6,6);
if(p!=(head-1)){ pa=p->next;p=pa;}
else p=head;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);
}}
if(flag==2)
{ window(6,5,,,0x0e);window(5,4,,,0x5e); window(6,5,,,0x0e);
putchar(,4,0x5a,sm,); if(head)
{ pa=head; j=0;
do{ j++; i=0; window(6,5,,,0x0e); gotoxy(,);
printf("Page%d",j);
do
{ if(pa->c<||pa->h maths<||pa->english<)
{ gotoxy(6,6+i); i++;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);}
pb=pa; pa=pb->next; }while(i!=&&pa!=0);
while(!key pressed()) now time();
get key(); }while(pa!=0);
goto out;}}
while(!key pressed())
now time();get key();
out:window(5,4,,,0x1e);}
/*成绩排名*/
void sort(void)
{ int i,j,n,flag; struct student*pa=0,*pb=0;
struct student*p[],*pmin;
char*str="NO. Name H maths English C\\C++ Sum S NO.";
window(6,5,,,0x0e); window(5,4,,,0x5e); window(6,5,,,0x0e);
putstr(,4,0x5a,str,); window(,,,,0x5b);
if(head!=0)
{ i=0; pb=pa=head;
do
{ p[i]=pa; i++; pa->sum=pa->h maths+pa->english+pa->c;
pb=pa; pa=pb->next; }while(pa!=0);
for(n=record n-1,i=0;i<n;i++)
{ flag=0;
for(j=0;j<n-i;j++)
if(p[j]->sum<p[j+1]->sum)
{ pmin=p[j]; p[j]=p[j+1]; p[j+1]=pmin; flag=1; }
if(flag==0)break; }
head=pb=pa=p[0]; head->s sum=1;
if(record n>1)
for(i=1;i<record n;i++) { pa->s sum=i; pb=pa; pa=pb->next=p[i];}
p2=p1=p[record n-1]; p1->s sum=record n;
p1->next=0; pb=pa=head;
j=0;
do{
j++;i=0; window(6,5,,,0x0e); gotoxy(,); printf("Page%d",j);
do
{ gotoxy(6,6+i); i++;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);}
pb=pa; pa=pb->next; }while(i!=&&pa!=0);
while(!key pressed()) now time();
get key(); }while(pa!=0);
goto out;}
while(!key pressed())
now time();get key();
out:window(5,4,,,0x1e);}
/*输入文件名*/
int input filename(int m)
{ char*p; int fp; menu window(,,,);
window(,,,,0x);
gotoxy(,); printf("File name");
if(!getstring(,,)) goto no;
if(key buf[1]==0) goto no;
p=key buf+2; key buf[key buf[1]+2]='\0';
if(fp=fopen(p,"rb+"))==0)
{ if(m==2) goto no; if(fp=fopen(p,"wb+"))==0 goto no; }
fclose(fp); strcpy(filename,p);
yes: window(,,,,0x1e);
return(1);
no: window(,,,,0x1e);
return(0);
}
/*新建文件*/
void new file(void)
{ int fp;
if(input filename(1)==0) info(9;
else
{ main menu 2(); free data(); fp=fopen(filename,"wb+"); fclose(fp); info(); }
}
/*打开文件*/
void open file(void)
{ struct student*pa,*pb; int fp;
if(input filename(2)==0)info(6);
else
{ free data(); head=pb=pa=(struct student*)malloc(LEN); fp=fopen(filename,"rb+";
fread(&pa->num,LEN,1,fp);}
info(8); fclose(fp); input(1); }}
/*保存文件*/
void save fiel(void)
{ struct student8pa,*pb; int fp;
if((fp=fopen(filename,"rb+"))==0) fp=fopen(filename,"wb+");
pb=pa=head;
if(fp!=0&&head!=0)
{ do{ fwrite(&pa->num,LEN,1,fp); pb=pa; pa=pb->next;}while(pa!=0);
fclose(fp); }
info(7);
}
void about me(void)
{ int i; char*title="About Me"; char*str[]={ " I'M A BIG.BIG WORLD. "};
menu window(,5,,); putstr(,5,0x,title,);
for(i=0;i<;i++)putstr(,6+i,0x,str[i],);
while(!key pressed()) now time();
get key(); window(,5,,,0x1e);
}
system("PAUSE");
return EXIT_SUCCESS;
}
Cè¯è¨ç»¼å设计
å¦æ对楼主æ帮å©ï¼ç»ä¸ªé纳好ä¸ï¼è°¢è°¢å¦1.ç¨åºåæï¼å¯å¡«å¨ç¾ä½ãåä½ã个ä½çæ°åé½æ¯1ã2ã3ã4ãç»æææçæåååå»
æä¸æ»¡è¶³æ¡ä»¶çæåã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int i,j,k;
printf("\n");
for(i=1;i<5;i++) /*以ä¸ä¸ºä¸é循ç¯*/
for(j=1;j<5;j++)
for (k=1;k<5;k++)
{
if (i!=k&&i!=j&&j!=k) /*ç¡®ä¿iãjãkä¸ä½äºä¸ç¸å*/
printf("%d,%d,%d\n",i,j,k);
}
getch();
}
==============================================================
ãç¨åº2ã
é¢ç®ï¼ä¼ä¸åæ¾çå¥éæ ¹æ®å©æ¶¦ææãå©æ¶¦(I)ä½äºæçäºä¸å æ¶ï¼å¥éå¯æ%ï¼å©æ¶¦é«
äºä¸å ï¼ä½äºä¸å æ¶ï¼ä½äºä¸å çé¨åæ%ææï¼é«äºä¸å çé¨åï¼å¯å¯æ
æ7.5%ï¼ä¸å°ä¸ä¹é´æ¶ï¼é«äºä¸å çé¨åï¼å¯ææ5%ï¼ä¸å°ä¸ä¹é´æ¶é«äº
ä¸å çé¨åï¼å¯ææ3%ï¼ä¸å°ä¸ä¹é´æ¶ï¼é«äºä¸å çé¨åï¼å¯ææ1.5%ï¼é«äº
ä¸å æ¶ï¼è¶ è¿ä¸å çé¨åæ1%ææï¼ä»é®çè¾å ¥å½æå©æ¶¦Iï¼æ±åºåæ¾å¥éæ»æ°ï¼
1.ç¨åºåæï¼è¯·å©ç¨æ°è½´æ¥åçï¼å®ä½ã注æå®ä¹æ¶éæå¥éå®ä¹æé¿æ´åããããããã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
long int i;
int bonus1,bonus2,bonus4,bonus6,bonus,bonus;
scanf("%ld",&i);
bonus1=*0. 1;
bonus2=bonus1+*0.;
bonus4=bonus2+*0.5;
bonus6=bonus4+*0.3;
bonus=bonus6+*0.;
if(i<=)
bonus=i*0.1;
else if(i<=)
bonus=bonus1+(i-)*0.;
else if(i<=)
bonus=bonus2+(i-)*0.;
else if(i<=)
bonus=bonus4+(i-)*0.;
else if(i<=)
bonus=bonus6+(i-)*0.;
else
bonus=bonus+(i-)*0.;
printf("bonus=%d",bonus);
getch();
}
==============================================================
ãç¨åº3ã
é¢ç®ï¼ä¸ä¸ªæ´æ°ï¼å®å ä¸åæ¯ä¸ä¸ªå®å ¨å¹³æ¹æ°ï¼åå ä¸åæ¯ä¸ä¸ªå®å ¨å¹³æ¹æ°ï¼è¯·é®è¯¥æ°æ¯å¤å°ï¼
1.ç¨åºåæï¼å¨ä¸ä»¥å å¤æï¼å å°è¯¥æ°å ä¸ååå¼æ¹ï¼åå°è¯¥æ°å ä¸ååå¼æ¹ï¼å¦æå¼æ¹å
çç»æ满足å¦ä¸æ¡ä»¶ï¼å³æ¯ç»æã请çå ·ä½åæï¼
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "math.h"
#include "stdio.h"
#include "conio.h"
main()
{
long int i,x,y,z;
for (i=1;i<;i++)
{
x=sqrt(i+); /*x为å ä¸åå¼æ¹åçç»æ*/
y=sqrt(i+); /*y为åå ä¸åå¼æ¹åçç»æ*/
if(x*x==i+&&y*y==i+) /*å¦æä¸ä¸ªæ°çå¹³æ¹æ ¹çå¹³æ¹çäºè¯¥æ°ï¼è¿è¯´ææ¤æ°æ¯å®å ¨å¹³æ¹æ°*/
printf("\n%ld\n",i);
}
getch();
}
==============================================================
ãç¨åº4ã
é¢ç®ï¼è¾å ¥æå¹´ææææ¥ï¼å¤æè¿ä¸å¤©æ¯è¿ä¸å¹´ç第å 天ï¼
1.ç¨åºåæï¼ä»¥3æ5æ¥ä¸ºä¾ï¼åºè¯¥å æå两个æçå èµ·æ¥ï¼ç¶ååå ä¸5天å³æ¬å¹´ç第å 天ï¼ç¹æ®
æ åµï¼é°å¹´ä¸è¾å ¥æ份大äº3æ¶éèèå¤å ä¸å¤©ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int day,month,year,sum,leap;
printf("\nplease input year,month,day\n");
scanf("%d,%d,%d",&year,&month,&day);
switch(month) /*å 计ç®ææ以åæ份çæ»å¤©æ°*/
{
case 1:sum=0;break;
case 2:sum=;break;
case 3:sum=;break;
case 4:sum=;break;
case 5:sum=;break;
case 6:sum=;break;
case 7:sum=;break;
case 8:sum=;break;
case 9:sum=;break;
case :sum=;break;
case :sum=;break;
case :sum=;break;
default:printf("data error");break;
}
sum=sum+day; /*åå ä¸æ天ç天æ°*/
if(year%==0||(year%4==0&&year%!=0)) /*å¤ææ¯ä¸æ¯é°å¹´*/
leap=1;
else
leap=0;
if(leap==1&&month>2) /*å¦ææ¯é°å¹´ä¸æ份大äº2,æ»å¤©æ°åºè¯¥å ä¸å¤©*/
sum++;
printf("It is the %dth day.",sum);
getch();
}
==============================================================
ãç¨åº5ã
é¢ç®ï¼è¾å ¥ä¸ä¸ªæ´æ°x,y,zï¼è¯·æè¿ä¸ä¸ªæ°ç±å°å°å¤§è¾åºã
1.ç¨åºåæï¼æ们æ³åæ³ææå°çæ°æ¾å°xä¸ï¼å å°xä¸yè¿è¡æ¯è¾ï¼å¦æx>yåå°xä¸yçå¼è¿è¡äº¤æ¢ï¼
ç¶ååç¨xä¸zè¿è¡æ¯è¾ï¼å¦æx>zåå°xä¸zçå¼è¿è¡äº¤æ¢ï¼è¿æ ·è½ä½¿xæå°ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int x,y,z,t;
scanf("%d%d%d",&x,&y,&z);
if (x>y)
{ t=x;x=y;y=t;} /*交æ¢x,yçå¼*/
if(x>z)
{ t=z;z=x;x=t;} /*交æ¢x,zçå¼*/
if(y>z)
{ t=y;y=z;z=t;} /*交æ¢z,yçå¼*/
printf("small to big: %d %d %d\n",x,y,z);
getch();
}
==============================================================
ãç¨åº6ã
é¢ç®ï¼ç¨*å·è¾åºåæ¯Cçå¾æ¡ã
1.ç¨åºåæï¼å¯å ç¨'*'å·å¨çº¸ä¸ååºåæ¯Cï¼ååè¡è¾åºã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
printf("Hello C-world!\n");
printf(" ****\n");
printf(" *\n");
printf(" * \n");
printf(" ****\n");
getch();
}
==============================================================
ãç¨åº7ã
é¢ç®ï¼è¾åºç¹æ®å¾æ¡ï¼è¯·å¨cç¯å¢ä¸è¿è¡ï¼çä¸çï¼Very Beautiful!
1.ç¨åºåæï¼åç¬¦å ±æ个ãä¸åå符ï¼å¾å½¢ä¸ä¸æ ·ããããããã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
char a=,b=;
printf("%c%c%c%c%c\n",b,a,a,a,b);
printf("%c%c%c%c%c\n",a,b,a,b,a);
printf("%c%c%c%c%c\n",a,a,b,a,a);
printf("%c%c%c%c%c\n",a,b,a,b,a);
printf("%c%c%c%c%c\n",b,a,a,a,b);
getch();
}
==============================================================
ãç¨åº8ã
é¢ç®ï¼è¾åº9*9å£è¯ã
1.ç¨åºåæï¼åè¡ä¸åèèï¼å ±9è¡9åï¼iæ§å¶è¡ï¼jæ§å¶åã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int i,j,result;
printf("\n");
for (i=1;i<;i++)
{
for(j=1;j<;j++)
{
result=i*j;
printf("%d*%d=%-3d",i,j,result); /*-3d表示左对é½ï¼å 3ä½*/
}
printf("\n"); /*æ¯ä¸è¡åæ¢è¡*/
}
getch();
}
==============================================================
ãç¨åº9ã
é¢ç®ï¼è¦æ±è¾åºå½é 象æ£æ£çã
1.ç¨åºåæï¼ç¨iæ§å¶è¡ï¼jæ¥æ§å¶åï¼æ ¹æ®i+jçåçååæ¥æ§å¶è¾åºé»æ¹æ ¼ï¼è¿æ¯ç½æ¹æ ¼ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int i,j;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
if((i+j)%2==0)
printf("%c%c",,);
else
printf(" ");
printf("\n");
}
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼æå°æ¥¼æ¢¯ï¼åæ¶å¨æ¥¼æ¢¯ä¸æ¹æå°ä¸¤ä¸ªç¬è¸ã
1.ç¨åºåæï¼ç¨iæ§å¶è¡ï¼jæ¥æ§å¶åï¼jæ ¹æ®içååæ¥æ§å¶è¾åºé»æ¹æ ¼ç个æ°ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int i,j;
printf("\1\1\n"); /*è¾åºä¸¤ä¸ªç¬è¸*/
for(i=1;i<;i++)
{
for(j=1;j<=i;j++)
printf("%c%c",,);
printf("\n");
}
getch();
}
ãç¨åºã
é¢ç®ï¼å¤å ¸é®é¢ï¼æä¸å¯¹å åï¼ä»åºçå第3个æèµ·æ¯ä¸ªæé½çä¸å¯¹å åï¼å°å åé¿å°ç¬¬ä¸ä¸ªæ
åæ¯ä¸ªæåçä¸å¯¹å åï¼åå¦å åé½ä¸æ»ï¼é®æ¯ä¸ªæçå åæ»æ°ä¸ºå¤å°ï¼
1.ç¨åºåæï¼ãå åçè§å¾ä¸ºæ°å1,1,2,3,5,8,,....
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
long f1,f2;
int i;
f1=f2=1;
for(i=1;i<=;i++)
{
printf("%ld %ld",f1,f2);
if(i%2==0) printf("\n"); /*æ§å¶è¾åºï¼æ¯è¡å个*/
f1=f1+f2; /*å两个æå èµ·æ¥èµå¼ç»ç¬¬ä¸ä¸ªæ*/
f2=f1+f2; /*å两个æå èµ·æ¥èµå¼ç»ç¬¬ä¸ä¸ªæ*/
}
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼å¤æ-ä¹é´æå¤å°ä¸ªç´ æ°ï¼å¹¶è¾åºææç´ æ°ã
1.ç¨åºåæï¼å¤æç´ æ°çæ¹æ³ï¼ç¨ä¸ä¸ªæ°åå«å»é¤2å°sqrt(è¿ä¸ªæ°)ï¼å¦æè½è¢«æ´é¤ï¼
å表ææ¤æ°ä¸æ¯ç´ æ°ï¼åä¹æ¯ç´ æ°ã ãããããã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
#include "math.h"
main()
{
int m,i,k,h=0,leap=1;
printf("\n");
for(m=;m<=;m++)
{
k=sqrt(m+1);
for(i=2;i<=k;i++)
if(m%i==0)
{
leap=0;
break;
}
if(leap)
{
printf("%-4d",m);
h++;
if(h%==0)
printf("\n");
}
leap=1;
}
printf("\nThe total is %d",h);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼æå°åºææçâæ°´ä»è±æ°âï¼æè°âæ°´ä»è±æ°âæ¯æä¸ä¸ªä¸ä½æ°ï¼å ¶åä½æ°åç«æ¹åçäºè¯¥æ°
æ¬èº«ãä¾å¦ï¼æ¯ä¸ä¸ªâæ°´ä»è±æ°âï¼å 为=1çä¸æ¬¡æ¹ï¼5çä¸æ¬¡æ¹ï¼3çä¸æ¬¡æ¹ã
1.ç¨åºåæï¼å©ç¨for循ç¯æ§å¶-个æ°ï¼æ¯ä¸ªæ°å解åºä¸ªä½ï¼åä½ï¼ç¾ä½ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int i,j,k,n;
printf("'water flower'number is:");
for(n=;n<;n++)
{
i=n/;/*å解åºç¾ä½*/
j=n/%;/*å解åºåä½*/
k=n%;/*å解åºä¸ªä½*/
if(i*+j*+k==i*i*i+j*j*j+k*k*k)
printf("%-5d",n);
}
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼å°ä¸ä¸ªæ£æ´æ°å解质å æ°ãä¾å¦ï¼è¾å ¥,æå°åº=2*3*3*5ã
ç¨åºåæï¼å¯¹nè¿è¡å解质å æ°ï¼åºå æ¾å°ä¸ä¸ªæå°çè´¨æ°kï¼ç¶åæä¸è¿°æ¥éª¤å®æï¼
(1)å¦æè¿ä¸ªè´¨æ°æ°çäºnï¼å说æå解质å æ°çè¿ç¨å·²ç»ç»æï¼æå°åºå³å¯ã
(2)å¦æn<>kï¼ä½nè½è¢«kæ´é¤ï¼ååºæå°åºkçå¼ï¼å¹¶ç¨né¤ä»¥kçå,ä½ä¸ºæ°çæ£æ´æ°ä½ n,
éå¤æ§è¡ç¬¬ä¸æ¥ã
(3)å¦ænä¸è½è¢«kæ´é¤ï¼åç¨k+1ä½ä¸ºkçå¼,éå¤æ§è¡ç¬¬ä¸æ¥ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
/* zheng int is divided yinshu*/
#include "stdio.h"
#include "conio.h"
main()
{
int n,i;
printf("\nplease input a number:\n");
scanf("%d",&n);
printf("%d=",n);
for(i=2;i<=n;i++)
while(n!=i)
{
if(n%i==0)
{
printf("%d*",i);
n=n/i;
}
else
break;
}
printf("%d",n);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼å©ç¨æ¡ä»¶è¿ç®ç¬¦çåµå¥æ¥å®ææ¤é¢ï¼å¦ä¹ æ绩>=åçåå¦ç¨A表示ï¼-åä¹é´çç¨B表示ï¼
å以ä¸çç¨C表示ã
1.ç¨åºåæï¼(a>b)?a:bè¿æ¯æ¡ä»¶è¿ç®ç¬¦çåºæ¬ä¾åã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int score;
char grade;
printf("please input a score\n");
scanf("%d",&score);
grade=score>=?'A':(score>=?'B':'C');
printf("%d belongs to %c",score,grade);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼è¾å ¥ä¸¤ä¸ªæ£æ´æ°månï¼æ±å ¶æå¤§å ¬çº¦æ°åæå°å ¬åæ°ã
1.ç¨åºåæï¼å©ç¨è¾é¤æ³ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int a,b,num1,num2,temp;
printf("please input two numbers:\n");
scanf("%d,%d",&num1,&num2);
if(num1<num2)/*交æ¢ä¸¤ä¸ªæ°ï¼ä½¿å¤§æ°æ¾å¨num1ä¸*/
{
temp=num1;
num1=num2;
num2=temp;
}
a=num1;b=num2;
while(b!=0)/*å©ç¨è¾é¤æ³ï¼ç´å°b为0为æ¢*/
{
temp=a%b;
a=b;
b=temp;
}
printf("gongyueshu:%d\n",a);
printf("gongbeishu:%d\n",num1*num2/a);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼è¾å ¥ä¸è¡å符ï¼åå«ç»è®¡åºå ¶ä¸è±æåæ¯ãç©ºæ ¼ãæ°ååå ¶å®å符ç个æ°ã
1.ç¨åºåæï¼å©ç¨whileè¯å¥,æ¡ä»¶ä¸ºè¾å ¥çå符ä¸ä¸º'\n'.
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
char c;
int letters=0,space=0,digit=0,others=0;
printf("please input some characters\n");
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,
space,digit,others);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼æ±s=a+aa+aaa+aaaa+aa...açå¼ï¼å ¶ä¸aæ¯ä¸ä¸ªæ°åãä¾å¦2++++(æ¤æ¶
å ±æ5个æ°ç¸å )ï¼å 个æ°ç¸å æé®çæ§å¶ã
1.ç¨åºåæï¼å ³é®æ¯è®¡ç®åºæ¯ä¸é¡¹çå¼ã
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
int a,n,count=1;
long int sn=0,tn=0;
printf("please input a and n\n");
scanf("%d,%d",&a,&n);
printf("a=%d,n=%d\n",a,n);
while(count<=n)
{
tn=tn+a;
sn=sn+tn;
a=a*;
++count;
}
printf("a+aa+...=%ld\n",sn);
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼ä¸ä¸ªæ°å¦ææ°å¥½çäºå®çå åä¹åï¼è¿ä¸ªæ°å°±ç§°ä¸ºâå®æ°âãä¾å¦6=1ï¼2ï¼3.ç¼ç¨
æ¾åºä»¥å çææå®æ°ã
1. ç¨åºåæï¼è¯·åç §ç¨åº<--ä¸é¡µç¨åº.
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "conio.h"
main()
{
static int k[];
int i,j,n,s;
for(j=2;j<;j++)
{
n=-1;
s=j;
for(i=1;i<j;i++)
{
if((j%i)==0)
{
n++;
s=s-i;
k[n]=i;
}
}
if(s==0)
{
printf("%d is a wanshu",j);
for(i=0;i<n;i++)
printf("%d,",k);
printf("%d\n",k[n]);
}
}
getch();
}
==============================================================
ãç¨åºã
é¢ç®ï¼ä¸çä»ç±³é«åº¦èªç±è½ä¸ï¼æ¯æ¬¡è½å°ååè·³ååé«åº¦çä¸åï¼åè½ä¸ï¼æ±å®å¨
第次è½å°æ¶ï¼å ±ç»è¿å¤å°ç±³ï¼ç¬¬æ¬¡åå¼¹å¤é«ï¼
1.ç¨åºåæï¼è§ä¸é¢æ³¨é
2.ç¨åºæºä»£ç ï¼
å¤å¶ä»£ç 代ç å¦ä¸:
#include "stdio.h"
#include "stdio.h"
main()
{
float sn=.0,hn=sn/2;
int n;
for(n=2;n<=;n++)
{
sn=sn+2*hn;/*第n次è½å°æ¶å ±ç»è¿çç±³æ°*/
hn=hn/2; /*第n次åè·³é«åº¦*/
}
printf("the total of road is %f\n",sn);
printf("the tenth is %f meter\n",hn);
getch();
}
求一个小型学生理财系统的面向对象程序设计的源代码
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
const unsigned int COUNT = 5;//账户数量为5
typedef struct Money{
int Date;
float money;
Money *next;
}Income,Expense;
typedef struct{
Income *income;//收入记录
Expense *expense;//支出记录
float incomeaccount;//收入统计
float expenseaccount;//支出统计
int incomelenght;
int expenselenght;
}Account;
class AccountInformation{
private:
Account L[COUNT];
public:
AccountInformation();
~AccountInformation();
int InitAccount();
void getExpense(int choice[]);
void getIncome(int choice[]);
void addExpense(int choice,Expense *elem);
void addIncome(int choice,Expense *elem);
void updateIncome(int choice,Expense elem);
void updateExpense(int choice,Expense elem);
void deleteIncome(int choice,int date);
void deleteExpense(int choice,int date);
void countAll();
void saveInfo();
};
AccountInformation::AccountInformation()
{
InitAccount();
}
AccountInformation::~AccountInformation()
{
}
int AccountInformation::InitAccount()
{
for(int i=0;i<COUNT;i++)
{
L[i].income=new Income;
L[i].expense=new Expense;
if(L[i].income==NULL||L[i].expense==NULL)
{
cout<<"分配内存失败."<<endl;
return 0;
}
L[i].incomelenght=0;
L[i].expenselenght=0;
L[i].incomeaccount=0;
L[i].expenseaccount=0;
}
Money *Q,*P;
char s[2];
//读取收入信息
ifstream fin1("income.txt");
if(fin1.fail())
{
cout<<"文件打开失败!"<<endl;
return 0;
}
for(i=0;i<COUNT;i++)
{
fin1>>s;
Q=L[i].income;
while(s[0]!='#')
{
if((int)s[1]==0)
Q->Date=(int)s[0]-;
else
Q->Date=((int)s[0]-)*+(int)s[1]-;
fin1>>Q->money;
Q->next=new Income;
L[i].incomelenght++;
L[i].incomeaccount+=Q->money;
P=Q;
Q=Q->next;
fin1>>s;
}
P->next=NULL;
}
fin1.close();
//读取支出信息
ifstream fin2("expense.txt");
if(fin2.fail())
{
cout<<"文件打开失败!"<<endl;
return 0;
}
for(i=0;i<COUNT;i++)
{
fin2>>s;
Q=L[i].expense;
while(s[0]!='#')
{
if((int)s[1]==0)
Q->Date=(int)s[0]-;
else
Q->Date=((int)s[0]-)*+(int)s[1]-;
fin2>>Q->money;
Q->next=new Income;
L[i].expenselenght++;
L[i].expenseaccount+=Q->money;
P=Q;
Q=Q->next;
fin2>>s;
}
P->next=NULL;
}
fin2.close();
return 1;
}
void AccountInformation::getExpense(int choice[])
{
Expense *Q;
float m=0.0;
for(int i=0;i<COUNT;i++)
if(choice[i]!=0)
{
Q=L[choice[i]-1].expense;
cout<<"账户"<<choice[i]<<"的支出信息为"<<endl;
cout<<"DATE\tMONEY"<<endl;
while(Q!=NULL)
{
cout<<Q->Date<<"\t"<<Q->money<<endl;
Q=Q->next;
}
cout<<"账户"<<choice[i]<<"的总支出信息为"<<L[choice[i]-1].expenseaccount<<endl<<endl;
m+=L[choice[i]-1].expenseaccount;
}
cout<<"总支出信息为"<<m<<endl;
}
void AccountInformation::getIncome(int choice[])
{
Income *Q;
float m=0.0;
for(int i=0;i<COUNT;i++)
if(choice[i]!=0)
{
Q=L[choice[i]-1].income;
cout<<"账户"<<choice[i]<<"的收入信息为"<<endl;
cout<<"DATE\tMONEY"<<endl;
while(Q!=NULL)
{
cout<<Q->Date<<"\t"<<Q->money<<endl;
Q=Q->next;
}
cout<<"账户"<<choice[i]<<"的总收入信息为"<<L[choice[i]-1].incomeaccount<<endl<<endl;
m+=L[choice[i]-1].incomeaccount;
}
cout<<"总收入信息为"<<m<<endl;
}
void AccountInformation::addExpense(int choice,Expense *elem)
{
Expense *Q,*P;
Q=L[choice-1].expense;
while(Q!=NULL)
{
if(Q->Date==elem->Date)
{
Q->money+=elem->money;
L[choice-1].expenseaccount+=elem->money;
return ;
}
if(Q->Date>elem->Date&&P->Date<elem->Date)
break;
P=Q;
Q=Q->next;
}
P->next=elem;
elem->next=Q;
L[choice-1].expenseaccount+=elem->money;
L[choice-1].expenselenght++;
}
void AccountInformation::addIncome(int choice,Expense *elem)
{
Expense *Q,*P;
Q=L[choice-1].income;
while(Q!=NULL)
{
if(Q->Date==elem->Date)
{
Q->money+=elem->money;
L[choice-1].incomeaccount+=elem->money;
return ;
}
if(Q->Date>elem->Date&&P->Date<elem->Date)
break;
P=Q;
Q=Q->next;
}
P->next=elem;
elem->next=Q;
L[choice-1].incomeaccount+=elem->money;
L[choice-1].incomelenght++;
}
void AccountInformation::updateExpense(int choice,Expense elem)
{
Expense *Q;
Q=L[choice-1].expense;
while(Q!=NULL)
{
if(Q->Date==elem.Date)
{
Q->money=elem.money;
L[choice-1].expenseaccount=elem.money-Q->money;
return ;
}
Q=Q->next;
}
}
void AccountInformation::updateIncome(int choice,Expense elem)
{
Expense *Q;
Q=L[choice-1].income;
while(Q!=NULL)
{
if(Q->Date==elem.Date)
{
Q->money=elem.money;
L[choice-1].incomeaccount=elem.money-Q->money;
return ;
}
Q=Q->next;
}
}
void AccountInformation::deleteExpense(int choice,int date)
{
Expense *Q,*P;
Q=L[choice-1].expense;
if(Q->Date==date)
{
L[choice-1].expense=NULL;
L[choice-1].expenseaccount=0.0;
L[choice-1].expenselenght=0;
}
while(Q!=NULL)
{
if(Q->Date==date)
{
P->next=Q->next;
L[choice-1].expenseaccount-=Q->money;
L[choice-1].expenselenght--;
return ;
}
P=Q;
Q=Q->next;
}
}
void AccountInformation::deleteIncome(int choice,int date)
{
Expense *Q,*P;
Q=L[choice-1].income;
if(Q->Date==date)
{
L[choice-1].income=NULL;
L[choice-1].incomeaccount=0.0;
L[choice-1].incomelenght=0;
}
while(Q!=NULL)
{
if(Q->Date==date)
{
P->next=Q->next;
L[choice-1].incomeaccount-=Q->money;
L[choice-1].incomelenght--;
return ;
}
P=Q;
Q=Q->next;
}
}
void AccountInformation::countAll()
{
Expense *Q;
float allincome=0.0;//总收入
float allexpense=0.0;//总支出
float a[COUNT],b[COUNT],c[COUNT],d[COUNT];
int date1,date2;
for(int i=0;i<COUNT;i++)
{
//收入信息
Q=L[i].income;
date1=Q->Date;
date2=Q->Date;
while (Q!=NULL)
{
if(Q->Date<date1)
date1=Q->Date;
if(Q->Date>date2)
date2=Q->Date;
Q=Q->next;
}
a[i]=L[i].incomeaccount/(date2-date1);//单位时间收入
c[i]=L[i].incomeaccount;//账户总收入
allincome+=L[i].incomeaccount;//总收入
//支出信息
Q=L[i].expense;
date1=Q->Date;
date2=Q->Date;
while (Q!=NULL)
{
if(Q->Date<date1)
date1=Q->Date;
if(Q->Date>date2)
date2=Q->Date;
Q=Q->next;
}
b[i]=L[i].expenseaccount/(date2-date1);//单位时间支出
d[i]=L[i].expenseaccount;//账户总支出
allexpense+=L[i].expenseaccount;//总支出
}
int k[COUNT]={ 1,2,3,4,5};
int l[COUNT]={ 1,2,3,4,5};
int t;
float f;
for(i=0;i<COUNT-1;i++)
for(int j=i+1;j<COUNT;j++)
if(a[i]>a[j])
{
f=a[j];
a[j]=a[i];
a[i]=f;
t=k[j];
k[j]=k[i];
k[i]=t;
}
else if(c[i]>c[j])
{
f=c[j];
c[j]=c[i];
c[i]=f;
t=l[j];
l[j]=l[i];
l[i]=t;
}
cout<<"总收入为:"<<allincome<<endl;
cout<<"账户收入分别为:\t\t单位时间内账户收入为:"<<endl;
for(i=0;i<COUNT;i++)
cout<<"账户"<<l[i]<<"的收入为:"<<c[i]<<"\t账户"<<k[i]<<"的收入为"<<a[i]<<endl;
for(i=0;i<COUNT;i++)
{
k[i]=i+1;
l[i]=i+1;
}
for(i=0;i<COUNT-1;i++)
for(int j=i+1;j<COUNT;j++)
if(b[i]>b[j])
{
f=a[j];
a[j]=a[i];
a[i]=f;
t=k[j];
k[j]=k[i];
k[i]=t;
}
else if(d[i]>d[j])
{
f=c[j];
c[j]=c[i];
c[i]=f;
t=l[j];
l[j]=l[i];
l[i]=t;
}
cout<<"总支出为:"<<allincome<<endl;
cout<<"账户支出分别为:\t\t单位时间内账户支出为:"<<endl;
for(i=0;i<COUNT;i++)
cout<<"账户"<<l[i]<<"的支出为:"<<d[i]<<"\t账户"<<k[i]<<"的支出为"<<b[i]<<endl;
}
void AccountInformation::saveInfo()
{
Money *Q;
ofstream fout1("income.txt",ios::trunc);
if(fout1.fail())
{
cout<<"文件打开失败!"<<endl;
return ;
}
for(int i=0;i<COUNT;i++)
{
Q=L[i].income;
while(Q!=NULL)
{
fout1<<Q->Date<<" "<<Q->money<<'\n';
Q=Q->next;
}
fout1<<"#\n";
}
fout1.close();
ofstream fout2("expense.txt",ios::trunc);
if(fout2.fail())
{
cout<<"文件打开失败!"<<endl;
return ;
}
for(i=0;i<COUNT;i++)
{
Q=L[i].expense;
while(Q!=NULL)
{
fout2<<Q->Date<<" "<<Q->money<<'\n';
Q=Q->next;
}
fout2<<"#\n";
}
fout2.close();
}
void menu1(int choice[COUNT])
{
char s[5];
cout<<"