Re: [問題] 我是學程設的新手 可以救救我嗎?

看板Programming作者 (咕啾咕啾魔法陣)時間14年前 (2010/05/29 14:00), 編輯推噓2(2013)
留言15則, 4人參與, 最新討論串2/3 (看更多)
請看得懂的人 大家心照不宣 畢竟人不能太好(逃) ------------------------------ #include<stdio.h> struct stu{ int s[3]; int sum; int avg; }; inline static void * scanf_s(stu s[] ,int i2=6){ extern int i2; int &i=i2; for(int j(i);j;j--){ printf("%d:",6-j); scanf("%d%d%d",&s[j-1].s[0],&s[j-1].s[1],&s[j-1].s[2]); if(s[j-1].s[0]>100||s[j-1].s[1]>100||s[j-1].s[2]>100){ printf("error\n"); j++; continue; } if(s[j-1].s[0]<0||s[j-1].s[1]<0||s[j-1].s[2]<0){ printf("error\n"); j++; continue; } } for(int j(i);j;j--) printf("%d A:%d B:%d C:%d\n",6-j,s[j-1].s[0],s[j-1].s[1],s[j-1].s[2]); } extern void * sumavg(stu s[] ,volatile int &i){ for(int j(i);j;j--){ s[j-1].sum=s[j-1].s[0]+s[j-1].s[1]+s[j-1].s[2]; s[j-1].avg=s[j-1].sum/3; } for(int j(i);j;j--) printf("%d sum:%d avg:%d\n",6-j,s[j-1].sum,s[j-1].avg); } int main(){ stu s[5]; volatile int i=5; scanf_s(s); sumavg(s,i); getchar(); getchar(); } int i2=5; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.134.226.149 ※ 編輯: loveflames 來自: 140.134.226.149 (05/29 14:26)

05/29 15:57, , 1F
犯不著這樣吧, 沒有人要維護這樣的碼.
05/29 15:57, 1F

05/29 15:58, , 2F
這時代還不用Framework開發, 自己寫API時
05/29 15:58, 2F

05/29 15:58, , 3F
代早已過去...:b
05/29 15:58, 3F
※ 編輯: loveflames 來自: 140.134.226.149 (05/29 16:05)

05/29 16:07, , 4F
自己寫api?樓上回錯篇了吧
05/29 16:07, 4F

05/29 17:19, , 5F
寫啥API?
05/29 17:19, 5F

05/29 18:01, , 6F
該不會是以為我宣告了一個叫scanf_s的
05/29 18:01, 6F

05/29 18:06, , 7F
函式,就以為我實作MS complier的scanf
05/29 18:06, 7F

05/29 18:07, , 8F
_s吧....如果是的話還真囧
05/29 18:07, 8F

05/29 18:09, , 9F
那個不是標準C的東西,不是每個人都在
05/29 18:09, 9F

05/29 18:11, , 10F
用MS compiler的啊,一樓該不會是沒看
05/29 18:11, 10F

05/29 18:11, , 11F
懂吧
05/29 18:11, 11F
※ 編輯: loveflames 來自: 140.134.226.149 (05/29 18:13)

05/29 18:26, , 12F
這篇惡意的部份不是在scanf_s,而是在
05/29 18:26, 12F

05/29 18:29, , 13F
某些修飾詞跟小地方
05/29 18:29, 13F

05/29 18:30, , 14F
不覺得這個乍看很像C嗎
05/29 18:30, 14F
※ 編輯: loveflames 來自: 140.134.226.149 (05/29 18:43)

05/30 22:50, , 15F
像!太像了!
05/30 22:50, 15F
文章代碼(AID): #1C0AsL8A (Programming)
文章代碼(AID): #1C0AsL8A (Programming)