求C语言高手帮忙做个小程序!!!

作者&投稿:和鲁 (若有异议请与网页底部的电邮联系)
全部2000分 求c语言高手 帮我 做个小程序~

楼主貌似问过这个问题了吧,不是已经结帖了吗?

#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename( "EOF", "adoEOF" )//必需自带dll库函数
#include
#include
#include
#include "string.h"
#include
#include
#include

struct MYDATE{//自定义时间结构体。
int YEAR;
int MONTH;
int DAY;
};
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
void ItemX(int select);//数据库操作
BOOL saveFile(char* bookID,char *time,float price);//保存文件
BOOL DeleteFile(char* bookID,MYDATE data,float price);//删除文件记录,再保存
void PrintProviderError(_ConnectionPtr pConnection);//数据库出错处理
void PrintComError(_com_error &e);//数据库出错处理
void Begin(int &select);//起点
char* left(char *pch,int len);//字符串取左位
char* right(char *pch,int len);
int findString(char *pch,char *temp);//字符串取相同字符首地址。
int main(int argc, char* argv[])
{
if(FAILED(::CoInitialize(NULL)))
return 0;
int select=-1;
Begin(select);
//Wait here for the user to see the output
printf("谢谢使用.
本软件只提供学习参考,不得用于其它商业软件.
Email:worldk@163.com
"
"Press any key to continue...
");
getch();
::CoUninitialize();
return 0;
}
BOOL saveFile(char* bookID,char *time,float price)/*int x,int y,MYDATA data)*/
{
char buff[100];FILE *file;char* strfile="\0";
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile("borrow.dat", &FindFileData);

if (hFind == INVALID_HANDLE_VALUE) {
printf ("未找到文件 %d
", GetLastError ());
} else {
FindClose(hFind);
memset(buff,0,100);
file=fopen("borrow.dat","rb");
fseek(file,0,SEEK_END);
int len=ftell(file);
strfile=new char[len];
rewind(file);
fread(strfile,1,len+1,file); strfile[len]='\0';
fclose(file);
}
file=fopen("borrow.dat","wb");
//编号、租借日期、押金。略……x,y,data运算自加
fseek(file,0,SEEK_END);
sprintf(buff,"%s,%s,%.2f
",bookID,time,price*3);
fwrite(buff,1,strlen(buff),file);
fwrite(strfile,1,strlen(strfile),file);

fclose(file);
printf("写入文件成功
");
return TRUE;
}
int findString(char *pch,char *temp)
{
int len=strlen(pch);
int templen=strlen(temp);

printf("%d",len);
int pos=0;
char* pch1=pch;
char *pch2=temp;
while(*pch1)
{
for(int i=0;i<templen;i++)
{
if(*(pch1+i)!=temp[i])
break;
}
if(i==templen)
return pos;
pch1++;
pos++;
}
return -1;
};
char* left(char *pch,int len)
{
char* pch1=(char *)malloc( _MAX_PATH );
strcpy(pch1,pch);
pch1[len]='\0';
return pch1;
}
char* right(char *pch,int len)
{
char* pch1=(char *)malloc( _MAX_PATH );
strcpy(pch1,pch);
pch1+=len;
return pch1;
}
BOOL DeleteFile(char* bookID,MYDATE data,float price)/*int x,int y,MYDATA data)*/
{
char buff[100];FILE *file;char* strfile="\0";
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile("borrow.dat", &FindFileData);

if (hFind == INVALID_HANDLE_VALUE) {
printf ("未找到文件 %d
", GetLastError ());//未找到文件
return FALSE;
} else {
FindClose(hFind);
memset(buff,0,100);
file=fopen("borrow.dat","rb");
fseek(file,0,SEEK_END);
int len=ftell(file);
strfile=new char[len];
rewind(file);
fread(strfile,1,len+1,file); strfile[len]='\0';
fclose(file);
}
sprintf(buff,"%s,%d-%d-%d",bookID,data.YEAR,data.MONTH,data.DAY);
int pos=findString(strfile,buff);
if(pos==-1)
{
printf("文件中没有这条记录
");
return FALSE;
}
char choose;
int pos2=0;
printf("%s ,单价%.2f 找到
",buff,price);
//编号、租借日期、押金。略……x,y,data运算自加
switch(*bookID)
{
case 'b':printf("资费1元\/日
");break;
case 'v':printf("资费2元\/日
");break;
case 'r':printf("资费3元\/日
");break;
default:printf("不详\/日
");break;
}
do
{
fflush(stdin);
printf("是否删除(Y/N)
");
scanf("%c",&choose);
}while(!(choose=='Y' || choose=='y' ||choose=='n' || choose=='N'));
if(choose=='n' || choose=='N')
return FALSE;

char *strlef=(char *)malloc( _MAX_PATH );;
char *pch1=NULL;
if(pos==0) strlef="\0";
else
{
strlef=left(strfile,pos);
strlef[pos-1]='\0';
}
char *strright=right(strfile,pos);
pch1=strchr(strright,'
');
if(pch1==NULL)
{
printf("找字符串错误,文件操作
");
return FALSE;

}

char * temp;
temp=strlef;
if(pos!=0) strcat(temp,pch1);
else temp=pch1+1;
file=fopen("borrow.dat","wb");
/* fwrite(temp,1,strlen(temp),file);
// fwrite(strfile,1,strlen(strfile),file);
*/

fwrite(temp,1,strlen(temp),file);
fclose(file);
printf("文件删除记录成功
");
return TRUE;

}
void Begin(int &select)
{
select=-1;
do{ printf( "|----------------------------------------------|
"
"| 请输入选项编号(0——5): |
"
"|----------------------------------------------|
"
"| 1——创建音像图书库 |
"
"| 2——租借音像图书 |
"
"| 3——归还时音像图书 |
"
"| 4——购进音像图书 |
"
"| 5——报废音像图书 |
"
"| 0——退出系统 |
"
"|----------------------------------------------|
");
fflush(stdin);
printf("请选择:(0-5)");
scanf("%d",&select);
}while(!(select==1 ||select==2 || select==3 || select==4 ||select==5 ||select==0));
if(select==0)
return;
ItemX(select);
}
void ItemX(int select)
{
fflush(stdin);
HRESULT hr = S_OK;
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRst = NULL;
_CommandPtr pCmd = NULL;
_ParameterPtr pPrm = NULL;
FieldPtr pFld = NULL;
SYSTEMTIME recvtime,currenttime;//最好用其它方法,这里节省时间
_bstr_t strCnn("DRIVER=Driver do Microsoft Access (*.mdb);DBQ=myBook"); //本程序目录下的myBook.mdb数据库
char *filename="myBook.mdb";//文件名
char *tabname="BOOK"; //文件表名
_variant_t Column[5];
_variant_t vIndex;
Column[0]="BIANHAO";//字段1,字符型,编号
Column[1]="NAME"; //字段2,字符型,名称
Column[2]="PRICE"; //字段3,小数型,价格
Column[3]="TOTAL"; //字段4,整型, 总数
Column[4]="NOWCOUNT";//字段5,整型,库存
MYDATE data;
try
{
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
TESTHR(pRst.CreateInstance(__uuidof(Recordset)));
TESTHR(pCmd.CreateInstance(__uuidof(Command)));
_bstr_t strText;
char temp[100]={"SELECT * FROM BOOK"};
char bookID[100];
switch(select)
{
case 1:
printf("这个用源码实现非常困难,最好用专门的数据库程序工具(如Access,SQL,MYSQL等)...
"
"显示建好的数据库每条记录
这里用的是微软的mdb数据库
");

strText=("SELECT * FROM BOOK ");//SQL语句……
break;
case 2:
printf("请你输入编号:");
gets(bookID);
strcat(temp ," where BIANHAO='" );
strcat(temp,bookID);
strcat(temp, "'");
strText=temp;
printf("自动取的当前时间.(年-月-日)
");//个人方法可不同,略……
memset(¤ttime,0,sizeof(currenttime));
GetSystemTime(¤ttime);//取系统时间,如果系统有时区差,这里也会有时差。为节省时间,略……
break;
case 3:
printf("请输入编号:");
gets(bookID);
strcat(temp ," where BIANHAO='" );
strcat(temp,bookID);
strcat(temp, "'");
strText=temp;
do{
printf("请输入借出的日期(年-月-日)");//同上略
scanf("%d-%d-%d",&data.YEAR,&data.MONTH,&data.DAY);
}while(data.MONTH12 || data.DAY31);
break;
case 4:
printf("请你输入编号:");
gets(bookID);
strcat(temp ," where BIANHAO='" );
strcat(temp,bookID);
strcat(temp, "'");
strText=temp;
break;
case 5:
printf("请你输入编号:");
gets(bookID);
strcat(temp ," where BIANHAO='" );
strcat(temp,bookID);
strcat(temp, "'");
strText=temp;
break;
default:
strText=("SELECT * FROM BOOK ");
break;
}
pCmd->CommandText = strText;
//////数据库连接
pConnection->Open(strCnn, "", "", adConnectUnspecified);
pCmd->ActiveConnection = pConnection;
_variant_t Conn;
Conn.vt = VT_ERROR;
Conn.scode = DISP_E_PARAMNOTFOUND;
pRst->Open((_variant_t((IDispatch *) pCmd)),Conn,adOpenStatic,
adLockReadOnly, -1);

////////////

long count=pRst->GetRecordCount();
if(count<=0 && select!=4)
{
pRst->Close();
pConnection->Close();
printf("没有条记录
");

printf("按任意键回主菜单....
");
getch();
Begin(select);
return;
}
else if(count<=0 && select==4)
{
char temp[100];
char bookName[100];
float price;
printf("请你输入名称:(DOS下不支持中文输入)");scanf("%s",&bookName);
printf("请你输入价格:");scanf("%f",&price);
sprintf(temp,"INSERT into BOOK VALUES ('%s','%s',%f,1,1)",bookID,bookName,price);
pRst->Close();
pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("添加记录成功
");
}
else if(count>0)
{
char temp[100];
strcpy(temp,pCmd->CommandText);

pRst->MoveFirst();
long limit = 0;
limit = ((pRst->Fields->Count) - 1);
int intLineCnt = 0; printf("");
for(int i=0;i<5;i++)
{
if(i==2) printf("");
printf("%s",(LPCSTR)(_bstr_t)Column[i]);
}
printf("
");
while(!pRst->adoEOF)
{
printf("");
for (short iIndex = 0; iIndex <= limit; iIndex++)
{
vIndex = iIndex;
pFld = pRst->Fields->GetItem(&vIndex);
_variant_t FldVal = pFld->GetValue();

// Because Value is the default property of a
// Property object,the use of the actual keyword
// here is optional.
switch(FldVal.vt)
{
case (VT_DECIMAL):
printf("%.2f",//"Value = '%s'",
(float)(FldVal.iVal)/100);
printf("");
break;
case (VT_BOOL):
if(FldVal.boolVal)
{
printf("Value = 'True'");

}
else
{
printf("Value = 'False'");
}
printf("");
break;
case (VT_BSTR):
printf("%s",//"Value = '%s'",
(LPCSTR)(_bstr_t)FldVal.bstrVal);
printf("");
break;
case (VT_I4):
printf("%d",//"Value = '%d'",
(LPCSTR)FldVal.iVal);
printf("");
break;
case (VT_EMPTY):
printf("%d",//"Value = '%s'",
(LPCSTR)FldVal.lVal);
printf("");
break;
case VT_DATE:
VariantChangeType(&FldVal,&FldVal,VARIANT_NOVALUEPROP,VT_BSTR);
printf("%s",//"Value = '%s'",
(LPCSTR)(_bstr_t)FldVal.bstrVal);
printf("");
break;
default:
break;
}
}
intLineCnt++;
printf("
");
pRst->MoveNext();
}
pRst->MoveFirst();

_variant_t FldVal=pRst->Fields->GetItem(Column[3])->GetValue();
int total=FldVal.iVal;
FldVal=pRst->Fields->GetItem(Column[4])->GetValue();
int nowcount=FldVal.iVal;
FldVal=pRst->Fields->GetItem(Column[2])->GetValue();
float m_price=(float)FldVal.iVal/100;

switch(select)
{
case 2:
char buff[100];
char choose;

sprintf(temp,"UPDATE BOOK SET NOWCOUNT=%d WHERE BIANHAO='%s'",nowcount-1,bookID);

pRst->Close();
if(nowcount-1<0)
{
printf("对不起,库存已经为空,请以后再来
",total);
break;
}
sprintf(buff,"%d-%d-%d",currenttime.wYear,currenttime.wMonth,currenttime.wDay);
do
{
printf("出借时间""%s""是否确定(Y/N)",buff);
scanf("%c",&choose);
}while(!(choose=='Y' || choose=='y' ||choose=='n' || choose=='N'));
if(choose=='n' || choose=='N')
break;
saveFile(bookID,buff,m_price);//参数自己加,略……
pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("出借成功,现库存为%d
",nowcount-1);
break;
case 3:
if(!DeleteFile(bookID,data,m_price))//参数自己加,略……
break;
else
sprintf(temp,"UPDATE BOOK SET NOWCOUNT=%d WHERE BIANHAO='%s'",
nowcount+1,bookID);
pRst->Close();

pRst.CreateInstance(__uuidof(Recordset));
pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("成功修改了库存,现记录为%d
",nowcount+1);
break;
case 4:
sprintf(temp,"UPDATE BOOK SET TOTAL=%d,NOWCOUNT=%d WHERE BIANHAO='%s'",
total+1,nowcount+1,bookID);
pRst->Close();

pRst.CreateInstance(__uuidof(Recordset));
pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("成功修改了总数,现记录为%d
",total+1);
printf("成功修改了库存,现记录为%d
",nowcount+1);

sprintf(temp,"Select * FROM BOOK where BIANHAO='%s'",bookID);

break;
case 5:
sprintf(temp,"UPDATE BOOK SET TOTAL=%d,NOWCOUNT=%d WHERE BIANHAO='%s'",
total-1,nowcount-1,bookID);

pRst->Close();
if(nowcount-1<0)
{
printf("对不起,库存已经为空,总数量为%d
",total);
if(total==0)
{
sprintf(temp,"DELETE * FROM BOOK where BIANHAO='%s'",bookID);
pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("由于总数量为0,该记录将被彻底清除
");
}
break;
}
pRst.CreateInstance(__uuidof(Recordset));

pRst->Open(temp,pConnection.GetInterfacePtr(),
adOpenStatic,adLockReadOnly, -1);
printf("成功修改总数记录,现记录为%d
",total-1);
printf("成功修改库存记录,现记录为%d
",nowcount-1);

break;
}
}

pCmd.Release();
pRst.Release();
pConnection.Release();

printf("按任意键回主菜单....
");
getch();
Begin(select);
}

catch(_com_error &e)
{
PrintProviderError(pConnection);
PrintComError(e);
}

}
void PrintProviderError(_ConnectionPtr pConnection)
{
ErrorPtr pErr = NULL;

if( (pConnection->Errors->Count) > 0)
{
long nCount = pConnection->Errors->Count;
// Collection ranges from 0 to nCount -1.
for(long i = 0; i < nCount; i++)
{
pErr = pConnection->Errors->GetItem(i);
printf(" Error number: %x%s", pErr->Number,
pErr->Description);
}
}
}

void PrintComError(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());

// Print Com errors.
printf("数据库操作错误.先创建数据库文件.由于数据指针操作复杂,详细说明略
");
printf("Code = %08lx
", e.Error());
printf("Code meaning = %s
", e.ErrorMessage());
printf("Source = %s
", (LPCSTR) bstrSource);
printf("Description = %s
", (LPCSTR) bstrDescription);
}

犯了好几个错误的。
1,你破坏了指示循环次数的n
2,每次用完count没有恢复零,导致长度出错。
2,“^”运算符的意思是按位异或,冥运算要用函数pow。
3,判断相等用“==”。“=”是赋值号,返回值总是真,放在if里永远成立。
4,“sum=sum+1”?难道你要求所有同构数之和?应当把printf放在外层循环里以输出每个值。
//////////下面是更改的
#include
#include
void main()
{
int n,m,count=0,sum=0;
for(n=1;n<=1000;n++)
{
m=n;
count=0;
while(n>0)
{
n=n/10;
count=count+1;
}
n=m;
if(m==(m*m)%(int)(pow(10,count)))
{
printf("%d
",n);
sum+=n;
}
}
printf("
the sum : %d
",sum);

}
////////////这个是我自己写的
#include
#include
void main()
{
for(int i=0;i<10000;i++)
if((i*i-i)%(int)pow(10,int(log10(i)+1))==0)cout<<i<<endl;

}

似于“彩蛋”的小程序
在黑夜中,繁星闪耀,然后一枚枚焰火升空,爆炸,产生五彩的礼花,每个礼花过后,分别显示了Beat这四个大大的字母(嘿嘿!是我们项目小组的名字),然后屏幕上这四个闪耀,按任意键后返回原来的程序。

这样专业的程序设计?
好象要用到很专业的程序设计语言,比如计算机的图形的编程.
#include <graphics.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.14159
#define maxx 640
#define maxy 480

main()
{int i;
char c;
init();
draw();
c=getch();
}

init()
/*初始化图形系统函数*/
{int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi"); /*注意此处的路径*/
setbkcolor(1);
sky();
return;
}

sky()
{int x,y,i;
for(i=1;i<=500;i++)
{x=rand()%640;y=rand()%300;
putpixel(x,y,15);
putpixel(x+1,y,15);
}
for(i=1;i<=200;i++)
{x=rand()%640;y=300+rand()%100;
putpixel(x,y,15);
}
return;
}

draw()
{int i,j,k,x,y,dy;
setfillstyle(1,7);
for(i=1;i<=10;i++)
{setlinestyle(3,0,3);
x=100+rand()%400;dy=20+rand()%20;
for(k=1000;k>=500;k-=100)
{sound(k);delay(3000);}
nosound();
for(j=1;j<=10;j++)
{setcolor(i%16);
line(x,maxy-(j-1)*dy,x,maxy-j*dy);
delay(10000);
setcolor(0);
line(x,maxy-(j-1)*dy,x,maxy-j*dy);
}
for(k=6000;k>=3000;k-=100)
{sound(k);delay(20000);}
nosound();
setlinestyle(3,0,2);
drawellipse(x,maxy-(j-1)*dy);
}

return;
}

drawellipse(int x,int y)
{int i,j,x1,y1,a,b;
float q;
a=60+rand()%60;b=a-rand()%60;
for(i=2;i>=0;i--)
{
for(q=0;q<=2*PI;q+=0.12)
{setcolor(rand()%16);
x1=x+(a-i*30)*cos(q);
y1=y-(b-i*30)*sin(q);
line(x,y,x1,y1);
}
delay(50000);
setcolor(0);
for(q=0;q<=2*PI;q+=0.12)
{x1=x+(a-i*30)*cos(q);
y1=y-(b-i*30)*sin(q);
line(x,y,x1,y1);
}

}
return;
}

如果不是很有必要的话,还不如去用FLASH做算了,这样的,要伤好多的脑细胞.

受不了楼主!!!!!!!!!!!!!!!!!!开玩笑呢!!!!!!!!!!!!!!100分我给你费这劲啊~~~~~~~~~我闲的啊!!!!!!!!!!!!自己慢慢折腾去吧!!!!!!!!!!!!!!

光焰火的爆炸算法要做好的话
也是很花功夫的

用C做这个程序啊!!!!!还是小程序,你做做看!亏你想得出,干脆用汇编去做啊!

我不得不佩服楼主的想象力,这样的程序要是用C做出来的话,那就真有点牛了```


请C语言高手帮我编写几个小程序~(一定要用C++编写噢~)
第一个 void reverse_merge(List &A,List &B,List &C){ InitList(C);i=j=1; k=0;la_len=ListLength(A);lb_len=ListLength(B);while((i<=la_len)&&(j<=lb_len)){ GetElem(A,i,ai);GetElem(B,i,bi);if(ai<=bj){ ListInsert(C,++k,ai); ++i;} else ListInsert(C,...

高手帮帮忙做几道c语言编程题 急求
2.自己看c里的循环语句可以解决的 把式子中分母设为N 循环加1,乘以上次的值赋给式子,再,加起来赋给和,循环推出条件判断(可设为没个式子的值小于某个值时推出循环 ,你试着有WHILE做吧 3.#include<stdio.h> void main(){ int m,i;float a,b,c;a=0;scanf("%d",&m);for(i=2;i...

请高手用C语言帮忙做个编程的题目,谢谢了!
include <stdio.h> int IsDevided(int number,int dev){ if(number %dev == 0){ return 1;} return 0;} void EasyDone(int a){ int chose;int i,j;printf("Input your chose\\n1>能被3整除的"<Enter 1>","\\n2>能被5整除的<Enter 2>","\\n3>能被3或5整除的<Enter 3>\\n");s...

哪位高手能帮我编以下c语言的程序
2007-07-11 求一C语言程序,哪位高手帮帮我啊 2019-04-27 哪位高手能帮我解决一下这个关于C语言的编程题。。 2010-06-21 哪位高手能帮忙做下面C语言的试题,急用 3 2009-07-23 哪位C语言高手来帮我做一个C的程序丫···谢谢!!! 2010-10-11 哪位高手帮我解释一下下面的c语言程序问题; 更多类似...

用C语言写一段程序,高手快来哦!
printf("请输入%d个整数:", RANGE);for(i = 0; i< RANGE; i++) scanf("%d", x + i);sort(x);printf("排序后为:\\n");for(i = 0; i < RANGE; i++) printf("%d\\t", x[i]);printf("\\n请输入要搜索的整数:");scanf("%d", &y);i = search(x, y);if (i < 0...

C语言高手!!帮忙写个最短路径程序!!!
这是我们的一个实验,你可以参考一下 一、 需求分析 【问题描述】设计一个校园导游程序,为来访的客人提供各种信息查询服务。【基本要求】(1) 设计你所有学校的校园平面图,所含景点不少于10个。以图中顶点表示校内各景点,存放景点名称、代号、简介等信息;以边表示路径,存放路径长度等相关信息。(2...

求高手帮忙做一些C语言试题
C、scanf(” %d%d%d”,x, y, z);D、read (” %d%d%d”,&x,&y,&z);3、不能正确表示条件x≥y≥z的C语言表达式是:A、(x>=y)&(y>=z)C、(x>=y).AND.(y>=z)D、(x>=y>=z)4、已知“int a, b; scanf ( "%d%d", &a, &b );”。若为a和b...

请c语言高手帮忙,写一个程序,51单片机显示1234,2S后显示5678 ,一直循环...
include<reg51.h> define uchar unsigned char bit flag=1;uchar j,k;uchar code tab[]={ 0x06,\/*1*\/ 0x5B,\/*2*\/ 0x4F,\/*3*\/ 0x66,\/*4*\/ 0x6D,\/*5*\/ 0x7D,\/*6*\/ 0x07,\/*7*\/ 0x7F,\/*8*\/ };sbit P2_0=P2^0;sbit P2_1=P2^1;sbit P2_2=P2^2;sbit P2_3=P2...

请高手帮忙编写C语言程序,万分感谢!!
各个细节就不加说明了,因为你题目已经说了;本人是正在学C语言,为了帮你编这个程序用了1个小时左右,希望多多支持一下,如果发现有什么错误的地方,请留言;谢谢 ~~~include<stdio.h> void input(float *p,int n){ float a[n];int i;for(i=0;i<n;i++){ (p+i)=&(a+i);} } void outpu...

哪位高手帮我做一下这个C语言程序,谢了!
include <iostream.h> int len;void intout(long N,int B){\/\/将N转换成B进制 int t,m;t=N\/B;m=N%B;if (t<B){ cout<<t;cout<<m;return;} intout(t,B);cout<<m;} void decimal(float f,int B){ if(len>6)return;float t;t=f*B;if(t>1)cout<<(int)t;else cout<<...

鼓楼区18044404553: 请c语言高手帮忙 写个小程序 -
堵菊盐酸: #include <stdio.h>#include <string.h>void main(){int i;char buffer[80];//输入字符长度不超过80gets(buffer);for(i=0;i<strlen(buffer);i++)printf("%c",buffer[strlen(buffer)-i-1]);}测试已运行成功

鼓楼区18044404553: 哪位编程高手帮我编写一个小程序,要求C语言,谢谢了
堵菊盐酸: #include <stdio.h> void main() { printf("Hello World!"); }

鼓楼区18044404553: C语言作业真不会呀,求大神帮忙写一个小程序 -
堵菊盐酸: #include int main() { printf("C:\\ABC.TXT"); //半角字符,所以楼下的不对 return 0; }

鼓楼区18044404553: 求C语言大神帮小弟写写这个小程序,,万分感谢 -
堵菊盐酸: #include#include#include class math { private: int a[4]; //把 char 改为 intpublic: void sss(); void fff(); void shuming(); }; void math::shuming() { cout} void math::sss() { char a; int t = 1; cout cout cout cin>>a; switch(a) { case '1': fff();break; case '2': ...

鼓楼区18044404553: 求高手 C语言小程序 程序不要太长50行以内最好 要有新意,变态级别的可以 -
堵菊盐酸: /* * * KMP算法 * 算法思想详见数据结构,查找子串一节 * */ #include <stdio.h> #define MAXSIZE 128 /*定义next数组长度*/ int find_sub_string(const char *str, const char *substr); int main(void) { char *str = "hello world"; char *sub_str = "llo"; int ...

鼓楼区18044404553: 求高手帮忙编个C语言小程序! -
堵菊盐酸: 既然都在看考研题了,说明你对编程挺感兴趣,我就交流一下我的思路,希望对你有所帮助. 思路一:首先,我会建一个结点(带指针的结构体).不想输入该班人数那就定义一个结束标志end(end可以用一个数字来代替,这样写输入函数是也方便), do{提示信息;输入数据的函数;判断是否结束标志,是的话跳出;分配内存;写入数据;统计并记录频次}while(true);输出平均和频次. 思路二:当然,如果成绩数据不用保存的话,就不用建结点了,用一个temp来接收数据就就行.

鼓楼区18044404553: 求助C语言大神帮我做一个小程序,孩子学校要 我也不会啊、 -
堵菊盐酸: #include "stdio.h" #include "conio.h" #include "math.h" #include "string.h" main(){char a[]="abcd hgh s1&&&",ch; int i=0,j=0,k=0,l=0; FILE *fp; fp=fopen("d:\\liangnv.txt","w"); fputs(a,fp);fclose(fp); fp=fopen("d:\\liangnv.txt","r"...

鼓楼区18044404553: 请大家帮忙写一个C语言的小程序
堵菊盐酸: #include <stdio.h> #include <stdlib.h> void main() {int a,b;char ch;printf("please input two number a and b");scanf("%d%d",&a,&b);getchar();printf("\nplease select scal:");ch=getchar();if(ch='+')printf("\n%d\n",a+b);if(ch='-')printf...

鼓楼区18044404553: 请帮我做一个小的c语言程序 -
堵菊盐酸: int x=0,y=0;//x百万富翁给的钱,y陌生人给的钱 for (int i=1;i<=30;i++) { y+=10; if (i>1)x+=x*2; else x=1; }

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网